Skip to content
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

Closed
sondremare opened this issue Dec 19, 2017 · 4 comments
Closed

Refetching queries #2754

sondremare opened this issue Dec 19, 2017 · 4 comments

Comments

@sondremare
Copy link
Contributor

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

  • apollo-client@2.1.0
@kennethlynne
Copy link

Maybe the cache should be invalidated for components that are unmounted so that navigation to the screen will not get a cache hit?

@kennethlynne
Copy link

@kennethlynne
Copy link

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

@kennethlynne
Copy link

It is also worth checking out this approach: #1552 (comment) - simply passing a custom store to apollo and clearing it manually

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants