-
-
Notifications
You must be signed in to change notification settings - Fork 799
Don't assume default value for optional value type argument without default value #8754
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
Open
Conversation
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
Can you please revert the formatting changes? 🙂
Whoops... done
@glen-84
glen-84
changed the title
(削除) Don`t assume default value for optional value type argument without default value (削除ここまで)
(追記) Don't assume default value for optional value type argument without default value (追記ここまで)
Oct 28, 2025
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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>.