-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refetching queries #2754
Comments
Maybe the cache should be invalidated for components that are unmounted so that navigation to the screen will not get a cache hit? |
Worth giving https://github.com/lucasconstantino/apollo-cache-invalidation a shot? |
It is possible to add this to the updater #621 (comment) Although, a way to tell apollo to invalidate all its cache would make this simpler |
It is also worth checking out this approach: #1552 (comment) - simply passing a custom store to apollo and clearing it manually |
Intended outcome:
Our app uses a separate real-time provider to keep the app up to date on new events at all times. However, if the app has been in background too long, and the real time session has expired, we are unable to recover to an update to date state. We then do a "reFetchObservedQueries" to make sure we are up to date on everything. We expect all queries to be updated
Actual outcome:
Some queries will not be refetched. After some digging I found out why, and I am not calling it a bug. But I would love to brainstorm how to solve this problem.
The queries that would not be refetched have received a 'standby' fetch-policy. As far as I know, this happens for components that have been mounted and then unmounted, probably for performance reasons. The problem then arises when the end-user re-enters that component, and it uses the old cache from the first visit. I tried using the fetch-policy 'cache-and-network', which fixes this problem, but due to another bug (apollographql/react-apollo#1342) it will cause other failures.
Any thoughts on how to fix this problem I am having? Maybe have reFetchObservedQueries take an optional parameter to also refetch queries in standby? Or some way of invalidating queries that are in standby, so they get refetched upon secondary entry?
Version
The text was updated successfully, but these errors were encountered: