Open DaveRMaltby opened 9 months ago
I've tracked down the issue. Although in v13 the default value is still in the definition for this field that uses the DefaultValue attribute, turns out that the Optional<T>.From()
method has changed such that it ignores the default value.
REF: https://github.com/ChilliCream/graphql-platform/blob/main-version-13/src/HotChocolate/Core/src/Abstractions/Optional.cs#L165
Next, I'll look at the blame and try to figure out why the From()
method was changed. Maybe it is called with multiple purposes, such that in at least one case, a new Optional<T>()
(without the DefaultValue) is required.
If an overload of From()
method is needed, then for reference, the From
is setup (in a System.Linq.Expressions.Expression) to be called at https://github.com/ChilliCream/graphql-platform/blob/main-version-13/src/HotChocolate/Core/src/Types/Utilities/Serialization/InputObjectCompiler.cs#L318
The Blame points to #4965 which points to #4677. I'm in the works of creating a simple PR with unit test to fix this.
I've created a PR against the main-version-13 branch. Let me know if I need to do the same for the v14 (Main) branch. Thanks!
We do not allow PRs against version 13 branches ... all changes have to go against main
. We can cherrypick it to 13 once it went through the main branch.
Product
Hot Chocolate
Version
13.8.1
Link to minimal reproduction
https://github.com/Servant-Software-LLC/HotChocolate_DefaultValue_not_applied
Steps to reproduce
What is expected?
The output of the GraphQL call to this mutation is providing the DefaultValue that was to be applied to the MyInputObject.ValuesToRetrieveInBatch field. In v12, this value was applied to the property and so I expected it to likewise be applied in v13.
What is actually happening?
The Optional of the ValuesToRetrieveInBatch property has the value of 0.
Relevant log output
No response
Additional context
Maybe mutation calls directly to IExecutionResult bypass some intermediate steps in the pipeline that have been added in v13, whereas in v12 the default values were applied when calling IExecutionResult?