Skip to content

Conversation

@sachindshinde
Copy link
Contributor

@sachindshinde sachindshinde commented Jul 29, 2025

When a @requires edge needs a subgraph jump, this would sometimes cause the locally satisfiable key fields needed by that jump to be fetched from the parent group instead of the current group (which apparently was done as an optimization). This can be a problem, since canSatisfyConditions() only really guarantees the current group has those key fields.

This PR updates the code using the parent group to now explicitly check whether the locally satisfiable key can be fetched from that group, and if not, falls back to the current group (adding it as a parent, if needed). This lets us keep the optimization and avoid unnecessarily changing query plans.

Fixes #3113 and #2987 , and derives a simpler example test from the one given in #3246 .

@sachindshinde sachindshinde requested a review from a team as a code owner July 29, 2025 17:47
@changeset-bot
Copy link

changeset-bot bot commented Jul 29, 2025

🦋 Changeset detected

Latest commit: e30a72d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@apollo/query-planner Patch
@apollo/gateway Patch
@apollo/federation-internals Patch
@apollo/composition Patch
@apollo/query-graphs Patch
@apollo/subgraph Patch
apollo-federation-integration-testsuite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@apollo-librarian
Copy link

apollo-librarian bot commented Jul 29, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 287ee4595aed4e5c0f26fb00
Build Logs: View logs

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 29, 2025

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.

Copy link
Contributor

@duckki duckki left a comment

Choose a reason for hiding this comment

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

It makes sense. But, I just have a question.

@sachindshinde sachindshinde force-pushed the sachin/fix-inapplicable-key-during-requires-subgraph-jump branch from 610e7b9 to efe5b99 Compare July 30, 2025 17:13
@sachindshinde sachindshinde requested a review from duckki July 30, 2025 17:45
…nly try to collect its key fields from a subgraph that didn't have them.
@sachindshinde sachindshinde force-pushed the sachin/fix-inapplicable-key-during-requires-subgraph-jump branch from 3d51c1d to e30a72d Compare July 30, 2025 18:52
@sachindshinde sachindshinde merged commit e17173b into main Aug 1, 2025
17 checks passed
@sachindshinde sachindshinde deleted the sachin/fix-inapplicable-key-during-requires-subgraph-jump branch August 1, 2025 15:32
@github-actions github-actions bot mentioned this pull request Aug 1, 2025
sachindshinde added a commit that referenced this pull request Sep 17, 2025
…e fetched from the wrong group" (#3300)

Reverts #3293 , as we haven't finished fully testing whether the solution is sound (and we don't want to block any pending releases).
sachindshinde added a commit that referenced this pull request Oct 1, 2025
…ields are fetched from the wrong group"" (#3307)

Reverts #3300 (which reverted #3293), as we're finishing up testing and the original PR should be fine to merge soon.
sachindshinde added a commit to apollographql/router that referenced this pull request Oct 1, 2025
…s are fetched from the wrong node (#8016)

When a `@requires` edge needs a subgraph jump during fetch dependency graph processing, this would sometimes cause the locally satisfiable key fields needed by that jump to be fetched from the parent node instead of the current node (which apparently was done as an optimization). This can be a problem, since `GraphPath::can_satisfy_conditions()` only really guarantees the current node has those key fields.

This PR updates the code using the parent node to now explicitly check whether the locally satisfiable key can be fetched from that node, and if not, falls back to the current node (adding it as a parent, if needed). This lets us keep the optimization and avoid unnecessarily changing query plans.

This PR mirrors its JS equivalent at apollographql/federation#3293 , and fixes #6004 .
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.

Bug: Query Planner Fails to Build Query for Nested Entity Fields Decorated With @requires

3 participants