-
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
Leave fetchPolicy
unchanged when skip: true
(or in standby) and nextFetchPolicy
is available
#9823
Leave fetchPolicy
unchanged when skip: true
(or in standby) and nextFetchPolicy
is available
#9823
Conversation
concast.cleanup(() => { | ||
this.fetchCancelFns.delete(queryId); | ||
|
||
if (queryInfo.observableQuery) { | ||
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options); | ||
} | ||
}); | ||
concast.promise.then(cleanupCancelFn, cleanupCancelFn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In PR #9718, which has only landed on the release-3.7
branch so far, we replaced concast.cleanup
with an improved (internal) API called concast.beforeNext
. However, if we can just stop using concast.cleanup
, that would be another solution to the problems it has caused. There's one more spot where we rely on it, in getObservableFromLink
.
concastSources.length > 0 && | ||
queryInfo.observableQuery | ||
) { | ||
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The applyNextFetchPolicy
method is now called synchronously, immediately after the fetch policy was used to make a request (by calling fetchQueryByPolicy
above). This required some test changes where we previously assumed the fetchPolicy
should still be the same immediately after performing some async operation like refetching, but I strengthened several of those tests to show that the original fetchPolicy
is what's used when fetching. I consider this change an improvement since it eliminates the possibility of more than one query using the original fetchPolicy
before nextFetchPolicy
is applied.
if (fetchPolicy === "standby") { | ||
// Do nothing, leaving options.fetchPolicy unchanged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only do we avoid calling applyNextFetchPolicy
when options.fetchPolicy === "standby"
, but this empty conditional block ensures applyNextFetchPolicy
has no effect in that case. Defense in depth!
698e155
to
21b4f56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome - thanks @benjamn!
Fixes issue #9765, judging by the reproduction provided by @Titozzz.
It may be worth noting that
skip: true
andfetchPolicy: "standby"
are intended to be essentially synonymous, which is why I sometimes mention both together (like "standby/skip:true
").