Automatic Cache Update Not Working
See original GitHub issueHello! I am trying to take advantage of the Apollo automatic cache updates as described here, but when I try to update my single entity, the cache remains the same:
Here I make the mutation:
and here I check the cache afterwards to see if it has changed:
Despite the isHidden
flag being set by the mutation, it is not updated. Is there something I’m missing for automatic cache updates besides single entity, and request the ID and modified fields back in the mutation?
Here are my system facts:
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Reading and writing data to the cache - Apollo GraphQL Docs
To update cached data safely, see Combining reads and writes. If the cache is missing data for any of the query's fields, readQuery...
Read more >Automatic cache updates do not work in react apollo
When I update one of the reviews from the list to the server, react apollo does not automatically update the cached review:
Read more >GraphQL Cache Updates Made Easy - Christian Lüdemann
We looked at how the Apollo Client handles automatic cache updates using normalization, refetch queries, and manual updates of the cahce. We finished...
Read more >Advanced Topics on Caching – Angular
refetchQueries is the simplest way of updating the cache. ... a problem arises when later retrieving or updating paginated queries in the ...
Read more >GraphQL Mutations and Caching using Apollo Client
This would indicate that the mutation was complete. If the mutation cache was not updated, we would need to refresh the page to...
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
After looking into it some more, it looks like we hit this issue because our apollo client config specified:
Which for mutate we had thought meant always hit the network similarly to what it means for a query but it also means do not cache the result, which causes the update option to not be triggered and does not write anything to the cache. Seeing as this is expected behavior I’m closing this issue.
From what I can see it looks like the cache should be updating. Could you provide a runnable reproduction, preferably using codesandbox? It’s difficult to see what’s going on without being able to run the code. Issues in this repo are much more likely to be looked at if they have a runnable reproduction