useQuery returning old data after resetStore or clearStore in beta
See original GitHub issueIntended outcome:
Rerender components with correct empty state after clearStore or resetStore
Actual outcome:
apollo-client supplies old data
How to reproduce the issue:
Click on the clear store button… you can try to replace clearStore with ResetStore https://codesandbox.io/s/xenodochial-hooks-p0i15
My actual use case is calling logout mutation and then clearing / reseting the store. And since the useQuery return the old data after store reset, it does not redirects to login page.
Versions
System:
OS: macOS 10.15.3
Binaries:
Node: 13.3.0 - ~/.nvm/versions/node/v13.3.0/bin/node
npm: 6.13.1 - ~/.nvm/versions/node/v13.3.0/bin/npm
Browsers:
Chrome: 80.0.3987.132
Firefox: 71.0
Safari: 13.0.5
npmPackages:
@apollo/client: ^3.0.0-beta.39 => 3.0.0-beta.39
apollo-link-error: ^1.1.12 => 1.1.12
apollo-server-express: ^2.9.16 => 2.9.16
apollo-upload-client: ^12.1.0 => 12.1.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:5 (3 by maintainers)
Top Results From Across the Web
useLazyQuery returns old data after clearStore or resetStore
It always returns old data, even after running the logout function several times without reloading the app, even when the API response is ......
Read more >Reading and writing data to the cache
If the cache is missing data for any of the query's fields, readQuery returns null . It does not attempt to fetch data...
Read more >@apollo/client | Yarn - Package Manager
It allows you to easily build UI components that fetch data via GraphQL. ... Better handle deferred queries that have cached or partial...
Read more >React Query: after refetch my data is fetched but still the old ...
log() logs the new fetched data, but the function still returns the old data until refresh. import { useQuery, useMutation, useQueryClient } ...
Read more >Advanced Topics on Caching – Angular
clearStore () instead of client.resetStore() . Cache persistence. If you would like to persist and rehydrate your Apollo Cache from a storage ...
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
It doesn’t sound like there is an outstanding issue here, so closing. Thanks!
I’m also having this issue.
partialRefetch
does not seem to help, both in my application as well as your example codesandbox.