-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Do smarter root query diffing #113
Comments
Have you reversed the current and desired implementation examples? |
Oh, indeed I have! Thanks for the heads up. |
After talking to @martijnwalraven: Another option is to only do this for single fields, but not for arrays. That way the algorithm is much simpler, and we don't end up with some odd edge cases. |
jbaxleyiii
pushed a commit
that referenced
this issue
Oct 17, 2017
* Added scalars * Added the JSON example, removed typescript, added references.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Right now, if you do the following queries in succession:
The query diffing algorithm will refetch:
Instead of:
This was a decision to not implement a new query diffing/merging algorithm before alpha. So it still works now, but will refetch some data.
The fix
In the XXX sections in
diffAgainstStore
: https://github.com/apollostack/apollo-client/blob/8df914c21980fb323699fc795171b2aedf3f98e1/src/data/diffAgainstStore.ts#L186Instead of bailing out the first time we find a missing field, we should instead traverse all of the subtrees, and make a union of all of the actual missing fields. This requires an algorithm for recursively merging GraphQL SelectionSet ASTs, which isn't hard to build but is non-trivial.
Ideally, this merging algorithm would be a separate, well-tested NPM package that we can bring to the wider community, since it's totally agnostic to Apollo Client.
The text was updated successfully, but these errors were encountered: