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

Fix issue when using a type condition on an inaccessible type in @req… #1873

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented May 20, 2022

…uire

The @require(fields:) argument can use some type conditions to require
data specific to a subtype. And those condition can even be on an
@inaccessible type since "inaccessibility is about the federated API
schema, not about subgraphs.

However, this wasn't properly working because when the execution code
was extracting the "requirements" data to pass it to the subgraph having
the @require, the (federated) API schema we used, and consequently
when the code tried to get the definition for the type condition in the
@require, it didn't find any definition (since the type in question is
@inaccessible and so not in said API schema) and as a result the
corresponding fields were not included in the subgraph query.

This commit fixes this issue, ensuring we pass the full supergraph
(which has the @inaccessible elements) to the execution code so
that supergraph can be used when extracting required data.

There was also another place within query planning (in graphPath.ts
more precisely) where the code was looking up the possible
implementation types, in the supergraph, of the required @inaccessible
type, and was using the supergraph API to do so, which was incorrect
for the same reason. This commit fix that problem as well, passing
the full supergraph instead.

Fixes #1866

@netlify
Copy link

netlify bot commented May 20, 2022

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

Visit the deploys page to approve it

Name Link
🔨 Latest commit b3f0d80

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 20, 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.

@pcmanus
Copy link
Contributor Author

pcmanus commented Jun 13, 2022

As mentioned on that ticket, this PR also fixes #1873.

Copy link
Contributor

@benweatherman benweatherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question about how we version this, but the functionality looks good

gateway-js/src/executeQueryPlan.ts Show resolved Hide resolved
gateway-js/src/index.ts Show resolved Hide resolved
@pcmanus pcmanus force-pushed the 1866-missing-data-requires branch from 983cd57 to 6a54f73 Compare June 28, 2022 09:05
…uire

The `@require(fields:)` argument can use some type conditions to require
data specific to a subtype. And those condition can even be on an
`@inaccessible` type since "inaccessibility is about the federated API
schema, not about subgraphs.

However, this wasn't properly working because when the execution code
was extracting the "requirements" data to pass it to the subgraph having
the `@require`, the (federated) API schema we used, and consequently
when the code tried to get the definition for the type condition in the
`@require`, it didn't find any definition (since the type in question is
`@inaccessible` and so not in said API schema) and as a result the
corresponding fields were not included in the subgraph query.

This commit fixes this issue, ensuring we pass the full supergraph
(which _has_ the `@inaccessible` elements) to the execution code so
that supergraph can be used when extracting required data.

There was also another place within query planning (in `graphPath.ts`
more precisely) where the code was looking up the possible
implementation types, in the supergraph, of the required `@inaccessible`
type, and was using the supergraph API to do so, which was incorrect
for the same reason. This commit fix that problem as well, passing
the full supergraph instead.

Fixes apollographql#1866, apollographql#1863
@pcmanus pcmanus force-pushed the 1866-missing-data-requires branch from 6a54f73 to b3f0d80 Compare June 28, 2022 09:11
Copy link
Contributor

@benweatherman benweatherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐐

@pcmanus pcmanus merged commit d3734ef into apollographql:main Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fed 2 Gateway doesn't provide full selection set to requirer when @requires uses an @inaccessible object type
2 participants