-
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
Incrementally re-render results after refetch
or skip
when using @defer
with useSuspenseQuery
#11035
Conversation
🦋 Changeset detectedLatest commit: c2c0c35 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
9d7a037
to
b748191
Compare
…es from `refetch`/`fetchMore`
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 changes themselves look good to me.
Personally, I have to say that tap
makes the code harder for me to read - especially since the "tapping" part of tap
is used nowhere, so it's more of a returnWithCleanup
function.
I've checked the bundle sizes, and if we would just go back to the normal behavior of
const val = something()
somethingElse()
return something()
there would not be any relevant bundle difference:
apollo-client.min.cjs
goes up by 10 bytes,
dist/main.cjs
stays the same
only importing one of useBackgroundQuery
or useSuspenseQuery
even goes down by a few bytes.
=> If you are okay with it, could we keep things simple here?
@@ -67,6 +69,7 @@ export class InternalQueryReference<TData = unknown> { | |||
this.listen = this.listen.bind(this); | |||
this.handleNext = this.handleNext.bind(this); | |||
this.handleError = this.handleError.bind(this); | |||
this.initiateFetch = this.initiateFetch.bind(this); |
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.
For the next PR: I believe without the tap
calls, this bind
call is unneccessary now.
Closes #10679
When issuing a query with an
@defer
directive, callingrefetch
or enabling a query by disabling theskip
option would only re-render when the entire result was loaded. This felt like it defeated the purpose of the@defer
directive in these cases.This PR adds the ability to incrementally re-render results returned by
@defer
queries to match the behavior of the initial fetch.This PR also makes a first attempt at refactoring some of
QueryReference
to remove flag-based state and replace it with a status enum.NOTE: This PR attempts to add support for this for
fetchMore
, but there is currently a bug in core that prevents this from happening. There is a test that documents the existing behavior for completeness.Checklist: