-
Notifications
You must be signed in to change notification settings - Fork 328
federation/composition: fix coercion rules when we expand supergraphs #8770
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3254a8f
fix coercion rules when we expand supergraphs
briannafugate408 eda556d
wip w Duckki 01-13-2026
briannafugate408 754d55f
fix coercion rules and update tests to call the proper function
briannafugate408 b9aacf4
update tests to now account for coercion
briannafugate408 c840a59
linter
briannafugate408 782fc60
update coercion tests to match comments, update directive argument me…
briannafugate408 c726283
update test since we now coerce in parse instead of expansion
briannafugate408 e3b5b8e
group list logic together, makes logic clearer.
briannafugate408 fbeaad8
Merge branch 'dev' into FED-773
briannafugate408 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| use apollo_federation::subgraph::test_utils::build_and_validate; | ||
|
|
||
| #[test] | ||
| fn coerces_directive_argument_values() { | ||
| // Test that directive argument values are coerced correctly. | ||
| let schema = r#" | ||
| extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"]) | ||
|
|
||
| type Query { | ||
| test: T! | ||
| } | ||
|
|
||
| type T @key(fields: "id") { | ||
| id: ID! | ||
| x: Int! | ||
| } | ||
| "#; | ||
|
|
||
| let _subgraph = build_and_validate(schema); | ||
| // Success: schema validated after coercion | ||
| } | ||
|
|
||
| #[test] | ||
| fn coerces_field_argument_default_values() { | ||
| // Test that field argument default values are coerced correctly. | ||
| // The field argument expects String! but the default is a list ["id"] | ||
| // which should be coerced to "id". | ||
| let schema = r#" | ||
| extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"]) | ||
|
|
||
| type Query { | ||
| test: T! | ||
| } | ||
|
|
||
| type T @key(fields: "id") { | ||
| id: ID! | ||
| name(arg: String! = ["id"]): String! | ||
| x: Int! | ||
| } | ||
| "#; | ||
|
|
||
| let _subgraph = build_and_validate(schema); | ||
| // Success: schema validated after coercion | ||
| } | ||
|
|
||
| #[test] | ||
| fn coerces_input_field_default_values() { | ||
| // Test that input object field default values are coerced correctly. | ||
| // - `name` has an enum-like default value `Anonymous` which should be coerced for custom scalars | ||
| // - `age` expects Int but the default is a list [18] which should be coerced | ||
| let schema = r#" | ||
| extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"]) | ||
|
|
||
| type Query { | ||
| test(input: UserInput): String | ||
| } | ||
|
|
||
| input UserInput { | ||
| name: String = Anonymous | ||
| age: Int = [18] | ||
| } | ||
| "#; | ||
| let _subgraph = build_and_validate(schema); | ||
| // Success: schema validated after coercion | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| mod coercion_tests; | ||
| mod parse_expand_tests; | ||
| mod subgraph_validation_tests; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.