-
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 an unmounted query results in stale data after remount. #1290
Comments
I just tried out the new version of react-apollo and got rid of the |
Yeah, it should be compatible with Could you reproduce this error by forking |
My first attempt of reproducing it with a fairly similar approach actually works correctly... I must be overlooking something, will try to investigate a bit further. |
Hi guys!
I'm running into an issue with a mutation that should cause a refetch of a component that's currently unmounted. Brief scenario:
Lets say I've got 2 components,
ListComponent
andFormComponent
.ListComponent
is mapped to a list of items throughMyListQuery
,FormComponent
has acreateItem
mutation that hasMyListQuery
added to its refetch list. When the form is displayed, the list component is unmounted. When the form is published and the mutation promise has been resolved, we redirect back toListComponent
. The code looks something like this:After the form is submitted, the mutation has been performed and we redirect back to the list, I'm expecting the list to either contain the new item, or to show a loader when the query is still being refetched. However, it looks like
MyListQuery
gets removed fromQueryManager.observableQueries[]
since its component is unmounted. Because of this the QueryManager can't find a match when looking up the queries that need to be refetched. As a resultListComponent
just fetches its result from cache as it is unaware of the fact that its query result is now stale.Is there any way to solve this behavior without doing a
forceFetch
? Would it be a possibility to keep tracking queries even when they are unmounted, but flagging them as stale so that their refetch can be delayed until remount?Intended outcome:
When a refetch happens on a unmounted component's query, the component should be aware of the stale query after remounting and refetch accordingly.
Actual outcome:
Currently queries stop being observed after being unmounted so this behavior does not work.
The text was updated successfully, but these errors were encountered: