Skip to content

Conversation

sachindshinde
Copy link
Contributor

@sachindshinde sachindshinde commented Sep 29, 2025

This PR fixes a bug where query planning may unexpectedly error while planning an operation with a satisfiable @shareable mutation field.

Specifically, this PR:

  1. Updates query planning on mutation fields to only consider one initial subgraph at a time for a traversal, and returns the plan with lowest cost.
    • Previously, this was mixing up options that started in different subgraphs in the same traversal, which would sometimes generate query planning errors if those differing options were chosen. There were a few ways to fix this, but the least invasive/simplest was just to do multiple traversals, each with a limited initial subgraph.
  2. Updates a particular query planning optimization to avoid discarding an option if another option with less subgraph jumps/cost is found, if that option starts in a different subgraph and the option is for a mutation operation.

This PR is the equivalent of this JS repo PR.

Unrelatedly, this PR also fixes an error messaging issue when QP unexpectedly doesn't find a plan (this shouldn't happen, but if it did, it was previously using the wrong federation error enum and message).

@sachindshinde sachindshinde requested review from a team as code owners September 29, 2025 18:59
@apollo-librarian
Copy link

apollo-librarian bot commented Sep 29, 2025

❌ Docs preview failed

The preview failed to build.

Build ID: 3db70408e972aee482e91912
Build Logs: View logs

Errors

General: ENOSPC: no space left on device, mkdir '/tmp/librarian/remote-sources/apollographql/rover/main'

This comment has been minimized.

@sachindshinde sachindshinde force-pushed the sachin/fix-shareable-mutation-fields-in-qp branch from bb6a401 to 308f954 Compare September 29, 2025 19:10
@dariuszkuc
Copy link
Member

Corresponding JS fix

@sachindshinde sachindshinde changed the title fix(federation/query-planning): Prevent error for satisfiable @shareable mutation fields fix(federation/query-planning): Prevent error for satisfiable @shareable mutation fields Sep 29, 2025
@sachindshinde sachindshinde force-pushed the sachin/fix-shareable-mutation-fields-in-qp branch from 308f954 to fe269b1 Compare September 29, 2025 19:56
@sachindshinde sachindshinde force-pushed the sachin/fix-shareable-mutation-fields-in-qp branch from fe269b1 to ac12814 Compare September 29, 2025 22:37
@sachindshinde sachindshinde requested a review from a team as a code owner September 29, 2025 22:37
@sachindshinde sachindshinde force-pushed the sachin/fix-shareable-mutation-fields-in-qp branch from ac12814 to 2d9fa2f Compare September 29, 2025 23:11
@sachindshinde
Copy link
Contributor Author

@dariuszkuc
That PR has been split up, and this PR corresponds more closely to apollographql/federation#3304 now.

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.

Looks great! The fix makes sense and I confirmed the test is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants