My use case is to update the cache with the result from mutation and also refresh a query to get the side effects of the mutation, but this second step can happen without showing anything the user, while the result of the mutation is shown to the user.
When I don't provide refetchQueries, it updates the cache as expected with the result from mutation. When I pass it the refetchQueries, it waits until the refetchQueries completes to update anything.
If the refetchQueries contains queries which don't "conflict" with the mutation data, the cache is immediately updated.
When clicking on the button, it stops loading after 500ms but only updates data after 2 seconds.
By commenting out the refetchQueries option, you can verify that the data is updated after 500ms.
I've also added a separate query that doesn't contain mutation data, and when I only list that one in the refetchQueries, it updates the cache immediately. (needs to be changed in the code, App.tsx lines 48-49)
Issue Description
My use case is to update the cache with the result from mutation and also refresh a query to get the side effects of the mutation, but this second step can happen without showing anything the user, while the result of the mutation is shown to the user.
When I don't provide refetchQueries, it updates the cache as expected with the result from mutation. When I pass it the refetchQueries, it waits until the refetchQueries completes to update anything.
If the refetchQueries contains queries which don't "conflict" with the mutation data, the cache is immediately updated.
Link to Reproduction
https://github.com/prscoelho/mutation-cache-update
Reproduction Steps
I have added the following delays in the repro:
When clicking on the button, it stops loading after 500ms but only updates data after 2 seconds.
By commenting out the refetchQueries option, you can verify that the data is updated after 500ms.
I've also added a separate query that doesn't contain mutation data, and when I only list that one in the refetchQueries, it updates the cache immediately. (needs to be changed in the code, App.tsx lines 48-49)