Skip to content
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

reconstruct deferred queries with knowledge about fragments #2109

Merged
merged 22 commits into from
Dec 12, 2022

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Nov 15, 2022

Fix #2105
Fix #2099

When we are using @defer, response formatting must apply on a subset of the query (primary or deferred), that is reconstructed from information provided by the query planner: a path into the response and a subselection. Previously, the query planner did not add fragments to that path, which resulted in reconstruction issues for queries like:

query {
  me {
    ... on User {
      id
      fullName
      memberships {
        permission
        account {
          ... on Account @defer {
            name
          }
        }
      }
    }
  }
}

we would get a deferred part with the path /me/memberships/account and the subselection { name }. The path does not give enough information to reconstruct the query when me returns an interface: we cannot know which type is used.

The query planner 2.2.2 introduces a fragment in the path to solve that, like /me/... on User/memberships/account. It also removes the 'flatten' element from deferred nodes paths, so the code has to be adapted a bit.

@github-actions

This comment has been minimized.

@Geal Geal changed the title split queries between primary and deferred parts reconstruct deferred queries with knowledge about fragments Dec 9, 2022
@Geal Geal requested review from a team, SimonSapin and BrynCooke and removed request for a team December 9, 2022 08:43
@Geal
Copy link
Contributor Author

Geal commented Dec 9, 2022

asking for a review on this before it is done, because the code is finished but it's waiting for a query planner and router-bridge release

@Geal Geal marked this pull request as ready for review December 12, 2022 10:16
@Geal Geal enabled auto-merge (squash) December 12, 2022 11:07
@Geal Geal merged commit 865d1f7 into dev Dec 12, 2022
@Geal Geal deleted the geal/split-queries branch December 12, 2022 11:17
@Geal Geal self-assigned this Dec 12, 2022
Geal pushed a commit that referenced this pull request Dec 12, 2022
Fix #1818 
Fix #2185
Blocked by #2109 (waiting for the router-bridge update)

When errors are generated during the primary execution, some of them can
be affected to
deferred responses.

To handle that, we need to:
- transmit errors from the primary query to deferred node execution
along with the primary fetches
- be able to check if an error path belongs to a deferred query

Since the error path may belong to a part of the response that was
nullified, we need to follow the error path through the primary or
deferred queries

Co-authored-by: Jeremy Lempereur <[email protected]>
@BrynCooke BrynCooke added this to the v1.6.0 milestone Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query reconstruction for deferred responses ignores fragments @defer directive should work with mutations
3 participants