Don't assume default value for optional value type argument without default value#8754
Merged
michaelstaib merged 12 commits intoChilliCream:mainfrom Feb 21, 2026
Merged
Don't assume default value for optional value type argument without default value#8754michaelstaib merged 12 commits intoChilliCream:mainfrom
michaelstaib merged 12 commits intoChilliCream:mainfrom
Conversation
Collaborator
|
Can you please revert the formatting changes? 🙂 |
Contributor
Author
|
Whoops... done |
src/HotChocolate/Core/src/Types/Utilities/Serialization/InputObjectCompiler.cs
Outdated
Show resolved
Hide resolved
src/HotChocolate/Core/test/Types.Tests/Types/InputParserTests.cs
Outdated
Show resolved
Hide resolved
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 #6347 (in this specific format)
Background:
This issue appears to be a side effect of #5317 and/or #4354.
If an optional value type argument was not present in the input arguments, the InputParser was changed in 5317 to emit the default value for that type.
This was necessary to avoid compilation failures as
nullcan not be converted to the value type.This PR removes this special handling from the InputParser and instead coalesces null arguments into the default value within the compiler itself.
This approach is very similar to how optional values are handled and allows the InputParser to correctly preserve an explicit null argument.
General note: This seems to only affects code-first types. For annotation-based types, we already have the correct nullability information, as an argument of type int? is in fact a Nullable whose default value is null.
Anyhow, for code-first types, this is not the case as f. e.
BooleanTypemaps to the runtime-typeboolinstead ofNullable<bool>.