You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement logout functionality in my app, which resets / unmounts all of my views and wipes the apollo store. resetStore() wipes the store and refetches all active queries and causes problems because it refetches queries that the user is no longer authed for (as per #1552 ).
When a component is unmounted, instead of throwing away the ObservableQuery, we put it in a recycler to keep it alive. You can think of it like putting the ObservableQuery in the fridge to be reheated later. When a new component mounts we take our saved ObservableQuery out of the fridge, add some new options, and use the old observable query again.
Now for every container component in your app (you create one whenever you call graphql) there should only be one ObservableQuery that lives forever assuming that you only render our container component once at a time. If you render your component more than once at a time that should still be fine.
During the componentWillUnmount the component has 2 observables:
the observable from the actual query
when it gets unmounted, a second "empty" observable gets created (that the above PR refers to)
Because of this second observable, the query will always be considered active, thus causing it to refetch when resetStore() is called, thus causing my not-authed problem.
Intended outcome:
Unmounted components shouldnt be refetched on resetStore()
Actual outcome:
Unmounted components are refetched on resetStore()
How to reproduce the issue:
Mount a component with react-apollo, unmount it, apolloClient.resetStore()
The text was updated successfully, but these errors were encountered:
I'm trying to implement logout functionality in my app, which resets / unmounts all of my views and wipes the apollo store.
resetStore()
wipes the store and refetches all active queries and causes problems because it refetches queries that the user is no longer authed for (as per #1552 ).I think this is a "smaller more squashable bug" that arised from apollographql/react-apollo#462
[emphasis mine]
During the componentWillUnmount the component has 2 observables:
Because of this second observable, the query will always be considered active, thus causing it to refetch when
resetStore()
is called, thus causing my not-authed problem.Intended outcome:
Unmounted components shouldnt be refetched on resetStore()
Actual outcome:
Unmounted components are refetched on resetStore()
How to reproduce the issue:
Mount a component with react-apollo, unmount it,
apolloClient.resetStore()
The text was updated successfully, but these errors were encountered: