Repository navigation
Apply explicit null variable defaults when variables are omitted - #10424
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The reviewed changes include regression coverage and no unresolved blocking issues.
Review effort: Lite
Findings: None
What changed in this PR
Updates Core and Fusion variable coercion to preserve explicit null defaults for omitted nullable variables and forward them correctly.
Changes:
- Applies explicit
nullvariable defaults. - Adds Core, Fusion, and gateway regression tests.
- Verifies Fusion forwards coerced
nullvalues.
| File | Description |
|---|---|
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/VariableCoercionHelperTests.cs |
Tests Fusion null-default coercion. |
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/VariableCoercionTests.cs |
Tests gateway forwarding and execution. |
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/__snapshots__/VariableCoercionTests.Omitted_Variable_With_Null_Default_Overrides_Argument_Default.yaml |
Captures expected forwarded null behavior. |
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/VariableCoercionHelper.cs |
Applies explicit defaults in Fusion. |
src/HotChocolate/Core/test/Execution.Tests/Processing/VariableCoercionHelperTests.cs |
Tests Core null-default coercion. |
src/HotChocolate/Core/test/Execution.Tests/Integration/Spec/ArgumentCoercionTests.cs |
Verifies null overrides argument defaults. |
src/HotChocolate/Core/src/Types/Execution/Processing/VariableCoercionHelper.cs |
Applies explicit defaults in Core. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Patch coverage100.0% of changed lines covered (23/23)
Project coverage: 58.8% (299817/509758 lines) |
glen-84
added a commit
that referenced
this pull request
Sep 24, 2026
This was referenced Sep 26, 2026
Merged
This was referenced Oct 3, 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.
Summary
nullvariable default ($value: Int = null) when the request omits the variable, as Coercing Variable Values requires. Both helpers skipped anulldefault, so the variable was treated as not provided and an argument default such asfield(arg: Int = 5)resolved to5instead ofnull. This regressed in Adds ResultDocument to HotChocolate Core #8931 and affects every release since 16.0.0.nullto the subgraph as an explicit variable value, so the result no longer depends on how the subgraph handles the forwarded= nulldefault.nulldefault on them ($a: Int! = null).Test plan
VariableCoercionHelperunit test for an omitted variable with anulldefault, and anArgumentCoercionTestsexecution test whereecho(value: Int = 5)returnsnull.VariableCoercionHelperunit test, and a gateway test whose snapshot shows the subgraph receiving"value": nulland the response returningnull.VariableCoercionHelperTests,ArgumentCoercionTests,VariableCoercionIntegrationTests, andCodeFirstTests; FusionVariableCoercionHelperTestsandVariableCoercionTests) pass, as do the existing tests that usenullvariable defaults (IdAttributeTestsandSlicingArgumentsTests).Closes #10423