-
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
change re-subscription order #11431
change re-subscription order #11431
Conversation
fixes test "useReadQuery auto-resubscribes the query after its disposed"
|
// Avoid triggering reobserve when resubscribing | ||
observable["observers"].add(observer); |
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.
observable.filter
in the next line will call observable.subscribe
internally anyways, and we can prevent the request in the no-cache
case by temporarily setting fetchPolicy
to "standby"
this.subscription = observable | ||
.filter( | ||
(result) => !equal(result.data, {}) && !equal(result, this.result) | ||
) | ||
.subscribe(observer); |
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.
moving this up as the .subscribe
will lead to fetchConcastWithInfo
call Querymanager.getQuery
, which will create a new queryInfo
object (which is required to call forceDiff
)
if (originalFetchPolicy !== "no-cache") { | ||
observable.resetLastResults(); | ||
observable.forceDiff(); |
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.
forceDiff
here would create a subscription for observable. queryInfo
, which at that point in time is a unregistered, old queryInfo
.
make "useReadQuery handles auto-resubscribe on no-cache fetch policy" test pass
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.
Will make some tweaks in my branch, but thanks for digging into this for me!
8cd67f0
into
jerel/load-query-outside-react
fixes test "useReadQuery auto-resubscribes the query after its disposed",
but breaks the next one 😓(fixed it 🎉 )CC @jerelmiller take a look :)
Checklist: