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

[normalize] Mutations with the same variables overwrite previous results #122

Closed
micimize opened this issue Nov 23, 2020 · 2 comments
Closed

Comments

@micimize
Copy link
Contributor

If a mutation like createOrder($placeId: ID!) returns different orders every time, the new one will overwrite the old in the cache. This can lead to incorrect mutations results for reactive clients like graphql/client.dart and probably ferry as well: zino-hofmann/graphql-flutter#774 (comment).

I'm not sure what the best solution is, or if it is even an issue for normalize to solve itself.

@smkhalsa
Copy link
Member

Let me know if you think of a way around this, but it seems like the existing behavior is the expected behavior, even if it results in incorrect mutation results in some cases.

This should probably be addressed by simply not reading mutation results from the cache by default. In ferry, mutations use FetchPolicy.NetworkOnly by default, and the FetchPolicy is not coupled to reactivity.

If a user needs to use cached mutation results, they could use unique variables or define custom FieldPolicy read / merge functions to alter the default behavior.

@micimize
Copy link
Contributor Author

Ok – yeah that's kind of what I was leaning towards also. I think the real problem is the use of cacheAndNetwork due to the entanglement of ObservableQuery in graphql/client.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants