Updating cache with local resolvers doesn't update the UI
See original GitHub issueSee a minimal reproduction here, since it isn’t easy to explain: https://codesandbox.io/s/fervent-hawking-o2bt5
If you watch the console, you can see that when you click the button, the resolver is running and the new data is being written to the cache. However, the useQuery
query in the UI (App.js) is not rerunning, and the data is stale as a result.
Expected result
- The UI updates when I press the button to show the new value of the cache.
Versions
@apollo/client @ 3.0.0-beta.20
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Local resolvers - Apollo GraphQL Docs
Manage local data with GraphQL like resolvers. ... You'll also learn how to query and update the cache with the @client directive. ......
Read more >Update Apollo Cache after a mutation and get instant benefits ...
When I readQuery and log the result, it seems to have updated the cache already(I'm guessing it's an auto update since the type...
Read more >apollo client cache updates but ui does not - Stack Overflow
writeFragment only updates that particular key in the cache, while not updating any of the queries that actually generated it.
Read more >Updating the Store – Angular - GraphQL Code Generator
Using update gives you full control over the cache, allowing you to make changes to your data model in response to a mutation...
Read more >Cache Updates | urql Documentation
Local Resolvers passively compute results and change how Graphcache traverses and sees its locally cached data, however, for mutations and subscriptions we ...
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
@benjamn any plans to fix issues with Apollo Local state soon? I’ve been running into several issues with it. I like the idea of being able to do GraphQL on both client and server but it just seems the local state side of apollo has a lot of issues.
Just a follow up on my comments here. I create a code repo and I couldn’t reproduce the issue there. So obviously, something else is going on. For those who might find it useful: https://codesandbox.io/s/naughty-glitter-wzmof The actual cause for my issue was an undetected remount of the ApolloProvider which lead to the cache being cleaned.