Repository navigation
fix: avoid crash on invalid selection sets - #336
Merged
kamilkisiela merged 2 commits intoSep 22, 2026
Merged
Conversation
Contributor
…ection set `@requires`/`@key`/`@provides`/`@fromContext` selection sets are written against a single subgraph, but `SelectionResolver` and the auth rules resolve them against the merged supergraph state. When subgraphs disagree on a field's type, the selection can point at a field the merged type does not have, and both throw a raw `Error`. All `postSupergraphRules` ran in one pass, and `SatisfiabilityRule` built its graph at rule-construction time, so the throw beat `FieldsOfTheSameTypeRule` to reporting the mismatch that caused it. Run the selection-dependent rules in a second pass, only once the other rules confirmed the merged state is coherent. Costs one extra traversal on the happy path, ~2% on an 18-subgraph compose.
kamilkisiela
force-pushed
the
fix/composition-crash-on-unresolvable-selection-set
branch
from
September 22, 2026 14:23
eac3247 to
b937358
Compare
kamilkisiela
commented
Sep 22, 2026
kamilkisiela
deleted the
fix/composition-crash-on-unresolvable-selection-set
branch
September 22, 2026 14:44
kamilkisiela
pushed a commit
that referenced
this pull request
Sep 22, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @theguild/federation-composition@0.26.3 ### Patch Changes - [#336](#336) [`12a4834`](12a4834) Thanks [@kamilkisiela](https://github.com/kamilkisiela)! - Report composition errors instead of throwing when `@requires`, `@key`, `@provides`, or `@fromContext` selections cannot be resolved against the merged supergraph. Selection-dependent validation now runs only after the other supergraph rules confirm the merged state is valid. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Composition could throw while validating
@requires,@key,@provides, or@fromContextselection sets when subgraphs disagreed on a field type.The selection-dependent validation rules were running before other supergraph rules had a chance to report errors such as
EXTERNAL_TYPE_MISMATCH.This changes validation to:
Also adds a regression test for
EXTERNAL_TYPE_MISMATCHwith a field referenced by@requires.