{"action":"created","issue":{"url":"https://api.github.com/repos/sonaye/mobx-apollo/issues/10","repository_url":"https://api.github.com/repos/sonaye/mobx-apollo","labels_url":"https://api.github.com/repos/sonaye/mobx-apollo/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/sonaye/mobx-apollo/issues/10/comments","events_url":"https://api.github.com/repos/sonaye/mobx-apollo/issues/10/events","html_url":"https://github.com/sonaye/mobx-apollo/issues/10","id":257075034,"number":10,"title":"Remove auto-unwrapping using propName?","user":{"login":"pselden","id":709282,"avatar_url":"https://avatars1.githubusercontent.com/u/709282?v=4","gravatar_id":"","url":"https://api.github.com/users/pselden","html_url":"https://github.com/pselden","followers_url":"https://api.github.com/users/pselden/followers","following_url":"https://api.github.com/users/pselden/following{/other_user}","gists_url":"https://api.github.com/users/pselden/gists{/gist_id}","starred_url":"https://api.github.com/users/pselden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pselden/subscriptions","organizations_url":"https://api.github.com/users/pselden/orgs","repos_url":"https://api.github.com/users/pselden/repos","events_url":"https://api.github.com/users/pselden/events{/privacy}","received_events_url":"https://api.github.com/users/pselden/received_events","type":"User","site_admin":false},"labels":[{"id":657613085,"url":"https://api.github.com/repos/sonaye/mobx-apollo/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-09-12T14:58:12Z","updated_at":"2017-11-07T16:42:26Z","closed_at":"2017-09-12T16:20:43Z","author_association":"NONE","body":"There's this line here: https://github.com/sonaye/mobx-apollo/blob/master/src/index.js#L11 which unwraps the propName inside of the data object, if and only if there is only one key inside of it. To me, this is not very intuitive and has caused me a few headaches trying to get things to work where I named my class property something other than what my graphql returns. Could you consider removing that feature and just exposing the data directly?\r\n\r\n```js\r\nconst ORGS_QUERY = gql`{\r\n   organizations {\r\n     pageInfo {\r\n       hasMore\r\n     }    \r\n     edges {\r\n       id\r\n      name\r\n    }\r\n   }\r\n}`;\r\n\r\n\r\nclass OrganizationsStore {\r\n   constructor() {\r\n     query(this, 'organizationsQuery', { client: client, query: ORGS_QUERY });\r\n   }\r\n\r\n   @computed\r\n   get organizations() {\r\n     return this.organizationsQuery.data.organizations.edges; // woops, data is undefined because internally it's setting data= data.organizationsQuery, which doesn't exist in my schema\r\n   }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/sonaye/mobx-apollo/issues/comments/342543738","html_url":"https://github.com/sonaye/mobx-apollo/issues/10#issuecomment-342543738","issue_url":"https://api.github.com/repos/sonaye/mobx-apollo/issues/10","id":342543738,"user":{"login":"pselden","id":709282,"avatar_url":"https://avatars1.githubusercontent.com/u/709282?v=4","gravatar_id":"","url":"https://api.github.com/users/pselden","html_url":"https://github.com/pselden","followers_url":"https://api.github.com/users/pselden/followers","following_url":"https://api.github.com/users/pselden/following{/other_user}","gists_url":"https://api.github.com/users/pselden/gists{/gist_id}","starred_url":"https://api.github.com/users/pselden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pselden/subscriptions","organizations_url":"https://api.github.com/users/pselden/orgs","repos_url":"https://api.github.com/users/pselden/repos","events_url":"https://api.github.com/users/pselden/events{/privacy}","received_events_url":"https://api.github.com/users/pselden/received_events","type":"User","site_admin":false},"created_at":"2017-11-07T16:42:26Z","updated_at":"2017-11-07T16:42:26Z","author_association":"NONE","body":"Sorry to bring this back up again, but I did notice that there is a difference now between queries that return one value vs queries that return multiple values that just bit me because I was expecting it to be the data object instead.\r\n\r\nhttps://github.com/sonaye/mobx-apollo/blob/master/src/index.js#L11\r\n\r\nExample:\r\n\r\n```gql\r\nquery {\r\n   options {\r\n      id,\r\n      name\r\n   }\r\n}\r\n```\r\n\r\n```js\r\n@computed get options() {\r\n   return this.optionsQuery.data || []; // this doesn't actually work, since the first time it's resolved it's an ObservableObjectAdministration from mobx.\r\n}\r\n```\r\n\r\nIf there was no auto-unwrapping it would look like:\r\n\r\n```js\r\n@computed get options() {\r\n   return this.optionsQuery.data.options || []; // hurray, this works!\r\n}\r\n```\r\n\r\nAdditionally, it's not not clear to me that the data object differs if and only if there is one key (unless I read the code).\r\n\r\n```gql\r\nquery {\r\n   options {\r\n      id\r\n      name\r\n   }\r\n\r\n   anotherObject { }\r\n}\r\n```\r\n\r\nNow all of a sudden my second example works... but now if I refactor and pull anotherObject out of the query, it's a breaking change to my computed that doesn't even deal with anotherObject!\r\n\r\nI realize this is breaking change so shouldn't be taken lightly -- but just wanted to draw attention to it in case other people feel the same way.\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"pselden"}}