-
Notifications
You must be signed in to change notification settings - Fork 2k
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
introduce transformer from latest incremental format to legacy format #4319
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for compassionate-pike-271cb3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋 Supported commandsPlease post this commands in separate comments and only one per comment:
|
This comment has been minimized.
This comment has been minimized.
@yaacovCR The latest changes of this PR are available on NPM as Also you can depend on latest version built from this PR: |
This comment has been minimized.
This comment has been minimized.
@yaacovCR The latest changes of this PR are available on NPM as Also you can depend on latest version built from this PR: |
…from latest format
This comment has been minimized.
This comment has been minimized.
@yaacovCR The latest changes of this PR are available on NPM as Also you can depend on latest version built from this PR: |
This comment has been minimized.
This comment has been minimized.
@yaacovCR The latest changes of this PR are available on NPM as Also you can depend on latest version built from this PR: |
The last attempt to support the both the current and legacy incremental delivery format in #4316 was a flop.1 This PR introduces a new one:
The
legacyExecuteIncrementally()
function works just likeexperimentalExecuteIncrementally()
from the latest graphql v17 alpha but returns the legacy format.2The plan if this approach meets goals would probably be to introduce this as a separate library, perhaps capable of even more complex transformations. For now, you can use it instead of the latest graphql v17 alpha via canary release
graphql@canary-pr-4319
Footnotes
In that version we built a non-standard execution plan with one execution group per delivery group where the different execution groups had duplicated fields, instead of the spiffy non-duplicated version of the current format.
Why did this not work?
Consider the following operation:
Assuming
Hero.nonNullName
is a non-nullable field and happens to returnnull
, thenull
will "bubble up" tohero
, i.e. the initial response for our new algorithm will simply be:No deferred fragment will be delivered, because there is no where for a client to store this data => without undoing a received null. Our new algorithm manages this by simply discarding any requests to send deferred data whenever a
null
is returned.This could be kind of tricky; after all, the deferred fragment is declared at the root, before
hero
is encountered. The way this works is the all overlapping fields simultaneously at each level, and uses the information gathered to decide when to initiate deferral in a separate "execution plan step". For the root fields in our example, no special action is taken even though there is a deferred fragment at root, because the deferredhero
field overlaps with the non-deferredhero
. Whenhero
returnsnull
, we discard the request for nested deferred data.If deferral is not initiated, though, our algorithm still saves details about any requested deferral on all of the child selections. So for the non-error case, when planning the subfields of
hero
, the algorithm can still "remember" thatHero.name
was requested as deferred and deliver just that necessary bit.In introduce legacy incremental delivery entrypoint #4316, we hacked that "execution plan step" to create that separate deferred fragment as if that overlap didn't occur, but we forgot that this will break the previous case! If we kick off a deferred fragment separately at root, we will return that fragment even if the initial result returns
null
. ↩legacyExecuteIncrementally()
usesexperimentalExecuteIncrementally()
under the hood, transforming the resulting latest format into the legacy format. If the new type of null-bubbling introduced within the latest format is encountered, the error will bubble up to the root of the deferred fragment. ↩