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

Ensures key fields needed post-@require are fetched #2075

Merged
merged 2 commits into from
Aug 18, 2022

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Aug 17, 2022

Sometimes, a @require on some entity E in some subgraph A requires
that the query plan jumps from A to some other subgraph(s) to get the
requirements, and then that we use a key of E to jump back to A to
resume fetching the field having the @require. When that happens
the code was correctly finding the key need to do that "post-@require"
resuming, and was using it as "inputs" of the post-@require fetch,
but was assuming that those key fields had already fetched. And while
that's true in a number of situation, this is not guaranteed.

This fix ensures that we force fetching (pre-@require) those key
fields that are needed to resume post-@require.

Fixes #2069

@pcmanus pcmanus self-assigned this Aug 17, 2022
@netlify
Copy link

netlify bot commented Aug 17, 2022

👷 Deploy request for apollo-federation-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c93f851

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 17, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Sylvain Lebresne added 2 commits August 18, 2022 16:08
Sometimes, a `@require` on some entity `E` in some subgraph A requires
that the query plan jumps from A to some other subgraph(s) to get the
requirements, and then that we use a key of `E` to jump back to A to
resume fetching the field having the `@require`. When that happens
the code was correctly finding the key need to do that "post-@require"
resuming, and was using it as "inputs" of the post-@require fetch,
but was assuming that those key fields had already fetched. And while
that's true in a number of situation, this is not guaranteed.

This fix ensures that we force fetching (pre-@require) those key
fields that are needed to resume post-@require.

Fixes apollographql#2069
@pcmanus pcmanus force-pushed the f2069-requires-missing-fields branch from 2a78acb to c93f851 Compare August 18, 2022 14:11
@pcmanus pcmanus merged commit 93e8ffd into apollographql:main Aug 18, 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.

Incorrect query plan when @requires starts with local (non-external) fields
2 participants