Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryManager refactor #471

Closed
Poincare opened this issue Jul 26, 2016 · 1 comment
Closed

QueryManager refactor #471

Poincare opened this issue Jul 26, 2016 · 1 comment
Assignees

Comments

@Poincare
Copy link
Contributor

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.

Responsibilities

The 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.

Problems + Solutions

  1. 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:
  • Modify the query document
  • Diff the query against the store (unless it is a forceFetch)
  • Send the query over the network interface (write a APOLLO_QUERY_INIT to the store)
  • Receive the result and incorporate it into the store with a APOLLO_QUERY_RESULT

Each of these should be broken into pieces rather than placed into one monolithic method.

  1. fetchQueryOverInterface should not read from the store - see Don't read from store inside of fetchOverInterface #391. Right now, we do this to check if there are missing fields - this is not necessary and we shouldn't do it.
  2. 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.

Those 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!

@stubailo stubailo modified the milestone: New API/Refactor Sep 29, 2016
@stubailo stubailo modified the milestone: Release 0.5 Oct 15, 2016
@helfer
Copy link
Contributor

helfer commented Nov 17, 2016

Closing since I think this a little bit outdated now.

@helfer helfer closed this as completed Nov 17, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants