question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Updating cache with local resolvers doesn't update the UI

See original GitHub issue

See 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
lifeiscontentcommented, Jan 24, 2020

@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.

1reaction
mschipperheyncommented, Feb 27, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found