[Fusion] Coerce single element value for list variable#9750
Merged
Conversation
e33f0a8 to
ea3da0a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Fusion’s JSON variable coercion to follow the GraphQL spec’s List Input Coercion rule by allowing a non-list JSON value to be treated as a single-element list when the variable type is a list (fixing the behavior reported in #9749).
Changes:
- Update Fusion list-variable coercion to wrap non-array JSON values into a single-item
ListValueNode. - Add Fusion tests covering single-value-to-list coercion and related error cases.
- Add a matching core execution test asserting the error shape when a single value cannot be coerced to the list element type.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/JsonVariableCoercion.cs |
Implements single-value → single-item-list coercion for list-typed variables. |
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/VariableCoercionHelperTests.cs |
Adds Fusion test coverage for list coercion and error reporting. |
src/HotChocolate/Core/test/Execution.Tests/Processing/VariableCoercionHelperTests.cs |
Adds core test coverage for the error produced when the single value doesn’t match the list element type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced May 20, 2026
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.
Closes #9749