-
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
fetchPolicy "cache-and-network" forced to refetch after unrelated query finishes #7068
Comments
Is there any workaround for this issue? Maybe you could call |
@joshjg I don't know if you refer to
First, for every |
@javier-garcia-meteologica That's a good idea, but what about cases such as "reloading the page"? Unless, I dont understand very well the issue, for which I would like to apologize. :P Feel free to correct me if that's the case. :) |
@exapsy |
Ah yeah you're right. I'm sorry, it was a long night and totally I misread that! |
Here is a repro Of those commits only this one looks relevant: 1cd1df9 Sure enough, adding |
This bug still occurs on 3.7.0, is it going to be fixed soon? |
The application initializes:
watchQuery()
with fetchPolicy "cache-and-network" and waits for a responsequery()
and quickly receives the responseIntended outcome:
I would expect apollo client to process the response of
query()
and keep waiting for the firstwatchQuery
result.Actual outcome:
The plain
query
sends a notification that triggers a reobserve in thewatchQuery
, which makes a refetch.Step by step
Plain
query
finishes, callsstopQuery()
apollo-client/src/core/QueryManager.ts
Line 494 in bd778d1
Which makes a broadcast to all queries
apollo-client/src/core/QueryManager.ts
Line 653 in bd778d1
watchQuery
thinks it should be notified inshouldNotify
apollo-client/src/core/QueryInfo.ts
Lines 209 to 214 in bd778d1
Previously,
watchQuery
created a listener and it's now called.apollo-client/src/core/QueryInfo.ts
Line 183 in bd778d1
reobserve()
then makeswatchQuery
to refetch againVersions
3.2.0
The text was updated successfully, but these errors were encountered: