Skip to content

incremental: add new deferred fragments to the wrapped graphql result #4358

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

Merged
merged 3 commits into from
Aug 8, 2025

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Mar 21, 2025

alternative solution to #4357 in which we add the new deferred fragments to the wrapped graphql result

After an execution group "fails," i.e. a null has bubbled up too far, it fails the entire associated deferred fragment. But if the query includes a shared execution group between the failing deferred fragment and a non-failing deferred fragment with some unique subfields, those subfields will still be added to the graph for the failed deferred fragment, which is not present.

This throws an error, because the code assumes that in the situation above, i.e. a shared execution group between two fragments and some unique subfields, both of the deferred fragments must already be in the graph. So a runtime-error is triggered because some of the invariants we rely on when adding deferred fragments are violated.

But even if we didn't have an error, this would be an erroneous situation, as we should never add back a node to the graph that has been failed!

After this change, new deferred fragments are explicitly returned as part of the GraphQLWrappedResult and are only added at a single point when building the graph such that this error can be avoided entirely.

@yaacovCR yaacovCR requested a review from a team as a code owner March 21, 2025 09:05
Copy link

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

@yaacovCR yaacovCR changed the title alternative solution to #4357 add new deferred fragments to the wrapped graphql result Jul 17, 2025
@robrichard
Copy link
Contributor

I like this approach, i think this will translate well to the spec algorithms

@yaacovCR yaacovCR merged commit aae95e6 into graphql:next Aug 8, 2025
16 checks passed
@yaacovCR yaacovCR deleted the another-way branch August 8, 2025 21:27
@yaacovCR yaacovCR changed the title add new deferred fragments to the wrapped graphql result incremental: add new deferred fragments to the wrapped graphql result Aug 8, 2025
@yaacovCR yaacovCR added the PR: bug fix 🐞 requires increase of "patch" version number label Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: bug fix 🐞 requires increase of "patch" version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants