Prevent mutation from caching
See original GitHub issueI have an editable
element. On every change I send the serialized content to my server using a mutation, so one mutation per change.
Now cache entries in ROOT_MUTATION
pile up. The serialized string can be quite long. Is there any way to prevent a mutation from caching the result?
I use version ^3.0.0-beta.23
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Advanced topics on caching in Apollo Client
Refetching queries after a mutation In certain cases, writing an update function to update the cache after a mutation can be complex, or...
Read more >Mutations & Caching with GraphQL, Ember & Apollo Tutorial
One cool thing about Apollo is that you can manually control the contents of the cache. This is really handy, especially after a...
Read more >Caching in GraphQL: How to prevent excessive and ...
Learn how caching can be used to cache GraphQL requests to prevent ... It means that each field in a query/mutation schema can...
Read more >Login and updating the cache - Full stack open
We are using an effect hook to save the token's value to the state of the App component and the local storage after...
Read more >Prevent an Unnecessary Refetch with nextFetchPolicy and ...
The problem was due to a change in how the cache-and-network fetch ... response is to avoid doing a separate query after the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue, and kinda thought it would be a configuration in the cache to mark a mutation as not cacheable. But it’s on the mutation level.
no-cache
does not read or write to the cache.The docs for useMutation don’t show the fetchPolicy but it’s there.
@henryqdineen you can use the
onComplete
handler and use the client to write to the cache.Taken from the docs: https://www.apollographql.com/docs/tutorial/mutations/#expose-apollo-client-with-useapolloclient But I hastily updated the example to use the
writeQuery
, aswriteData
is deprecated and removed in v3.