-
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
writeQuery, writeFragment, or modify? #7756
Comments
@bstro I agree that section isn't as clear as it could be. I'll try to provide some more clarity.
What's being referred to here is the
Mutations that create or delete entities do not update the cache automatically. This is also true of mutations that deal with multiple entries. So, the above mutation will not add the newly created Todo to the cache. To do that, we need to use the
How you make those changes is up to you, depending on what you want to accomplish. Here's a good breakdown of how I'd also take a look at this comment for why I hope this helps! |
Really appreciate it, @jcreighton — This helps! |
Happy to help! |
I am unclear if this is an issue with documentation or my own understanding. With the existing documentation, its a bit fuzzy to me why I would choose one of these methods over the other—in one example in the Mutation docs, a writeFragment operation is even nested within a call to modify, unclear to me why.
I am further confused by this example from the docs:
— but then under the documentation for writeQuery and writeFragment, the docs state that
All subscribers to the Apollo Client cache (including all active queries) see this change and update your application's UI accordingly.
.So it is ultimately unclear to me how to get my queries to refresh when they depend on data from the cache, the docs seem contradictory, and unclear when I would use one over the other, and which ones will trigger a rerender from queries that watch the affected fields.
The text was updated successfully, but these errors were encountered: