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.

useQuery returning old data after resetStore or clearStore in beta

See original GitHub issue

Intended 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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
hwillsoncommented, Apr 30, 2021

It doesn’t sound like there is an outstanding issue here, so closing. Thanks!

1reaction
ryanwiesjahncommented, May 20, 2020

I’m also having this issue. partialRefetch does not seem to help, both in my application as well as your example codesandbox.

Read more comments on GitHub >

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

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