Skip to content

[Fusion] Coerce single element value for list variable#9750

Merged
tobias-tengler merged 1 commit into
mainfrom
tte/fix-fusion-variable-coercion
May 20, 2026
Merged

[Fusion] Coerce single element value for list variable#9750
tobias-tengler merged 1 commit into
mainfrom
tte/fix-fusion-variable-coercion

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

@tobias-tengler tobias-tengler commented May 20, 2026

Closes #9749

Copilot AI review requested due to automatic review settings May 20, 2026 10:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@tobias-tengler tobias-tengler merged commit c0a4a9e into main May 20, 2026
139 checks passed
@tobias-tengler tobias-tengler deleted the tte/fix-fusion-variable-coercion branch May 20, 2026 10:46
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.

Fusion doesn't automatically coerce single values into lists for variables

2 participants