{"action":"created","issue":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/471","repository_url":"https://api.github.com/repos/apollostack/apollo-client","labels_url":"https://api.github.com/repos/apollostack/apollo-client/issues/471/labels{/name}","comments_url":"https://api.github.com/repos/apollostack/apollo-client/issues/471/comments","events_url":"https://api.github.com/repos/apollostack/apollo-client/issues/471/events","html_url":"https://github.com/apollostack/apollo-client/issues/471","id":167665743,"number":471,"title":"QueryManager refactor","user":{"login":"Poincare","id":217352,"avatar_url":"https://avatars.githubusercontent.com/u/217352?v=3","gravatar_id":"","url":"https://api.github.com/users/Poincare","html_url":"https://github.com/Poincare","followers_url":"https://api.github.com/users/Poincare/followers","following_url":"https://api.github.com/users/Poincare/following{/other_user}","gists_url":"https://api.github.com/users/Poincare/gists{/gist_id}","starred_url":"https://api.github.com/users/Poincare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Poincare/subscriptions","organizations_url":"https://api.github.com/users/Poincare/orgs","repos_url":"https://api.github.com/users/Poincare/repos","events_url":"https://api.github.com/users/Poincare/events{/privacy}","received_events_url":"https://api.github.com/users/Poincare/received_events","type":"User","site_admin":false},"labels":[{"id":407084465,"url":"https://api.github.com/repos/apollostack/apollo-client/labels/refactor","name":"refactor","color":"bfdadc","default":false}],"state":"closed","locked":false,"assignee":{"login":"Poincare","id":217352,"avatar_url":"https://avatars.githubusercontent.com/u/217352?v=3","gravatar_id":"","url":"https://api.github.com/users/Poincare","html_url":"https://github.com/Poincare","followers_url":"https://api.github.com/users/Poincare/followers","following_url":"https://api.github.com/users/Poincare/following{/other_user}","gists_url":"https://api.github.com/users/Poincare/gists{/gist_id}","starred_url":"https://api.github.com/users/Poincare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Poincare/subscriptions","organizations_url":"https://api.github.com/users/Poincare/orgs","repos_url":"https://api.github.com/users/Poincare/repos","events_url":"https://api.github.com/users/Poincare/events{/privacy}","received_events_url":"https://api.github.com/users/Poincare/received_events","type":"User","site_admin":false},"assignees":[{"login":"Poincare","id":217352,"avatar_url":"https://avatars.githubusercontent.com/u/217352?v=3","gravatar_id":"","url":"https://api.github.com/users/Poincare","html_url":"https://github.com/Poincare","followers_url":"https://api.github.com/users/Poincare/followers","following_url":"https://api.github.com/users/Poincare/following{/other_user}","gists_url":"https://api.github.com/users/Poincare/gists{/gist_id}","starred_url":"https://api.github.com/users/Poincare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Poincare/subscriptions","organizations_url":"https://api.github.com/users/Poincare/orgs","repos_url":"https://api.github.com/users/Poincare/repos","events_url":"https://api.github.com/users/Poincare/events{/privacy}","received_events_url":"https://api.github.com/users/Poincare/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-07-26T17:31:31Z","updated_at":"2016-11-17T08:44:43Z","closed_at":"2016-11-17T08:44:43Z","body":"`QueryManager` has become pretty complex and we need to refactor it before the 1.0 release, as described in #464. I'm using this issue to write down what `QueryManager`'s responsibilities should include, some of the issues that currently plague `QueryManager` and how we can fix them.\n## Responsibilities\n\nThe `QueryManager` should be responsible for sending queries/mutations to the network interface, receiving the results and dispatching the actions to the store that are needed as part of this transaction, i.e. it should serve as the middleman between the store and the network interface and should expose a way to fetch queries or apply mutations. \n## Problems + Solutions\n1. `fetchQueryOverInterface` is way too complicated. We should simplify it by moving the document-changing-functions (e.g. adding fragments, applying query transformations, etc.) to a separate function. The basic logic of `fetchQueryOverInterface`:\n- Modify the query document\n- Diff the query against the store (unless it is a forceFetch)\n- Send the query over the network interface (write a `APOLLO_QUERY_INIT` to the store)\n- Receive the result and incorporate it into the store with a `APOLLO_QUERY_RESULT`\n\nEach of these should be broken into pieces rather than placed into one monolithic method.\n1. `fetchQueryOverInterface` should not read from the store - see #391. Right now, we do this to check if there are missing fields - this is not necessary and we shouldn't do it.\n2. `query` should not depend on `watchQuery`. It creates an observable for pretty much no reason and means that we need the `shouldSubscribe` hack to make error handling work correctly. Instead, we should just have `query` call `fetchQueryOverInterface` directly. \n\nThose seem to be the largest issues to me and once we have fixed those, we should have a pretty readable and robust QueryManager. Feedback appreciated!\n"},"comment":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/comments/261188247","html_url":"https://github.com/apollostack/apollo-client/issues/471#issuecomment-261188247","issue_url":"https://api.github.com/repos/apollostack/apollo-client/issues/471","id":261188247,"user":{"login":"helfer","id":6569980,"avatar_url":"https://avatars.githubusercontent.com/u/6569980?v=3","gravatar_id":"","url":"https://api.github.com/users/helfer","html_url":"https://github.com/helfer","followers_url":"https://api.github.com/users/helfer/followers","following_url":"https://api.github.com/users/helfer/following{/other_user}","gists_url":"https://api.github.com/users/helfer/gists{/gist_id}","starred_url":"https://api.github.com/users/helfer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helfer/subscriptions","organizations_url":"https://api.github.com/users/helfer/orgs","repos_url":"https://api.github.com/users/helfer/repos","events_url":"https://api.github.com/users/helfer/events{/privacy}","received_events_url":"https://api.github.com/users/helfer/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T08:44:43Z","updated_at":"2016-11-17T08:44:43Z","body":"Closing since I think this a little bit outdated now."}}
{"actor":{"display_login":"helfer"}}