Fix argument coercion for non-typed list elements - #9957
#9957Fix argument coercion for non-typed list elements#9957
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Hot Chocolate input argument coercion for lists whose element type is an input object that may be materialized as a Dictionary<string, object> (e.g., when input object fields are not runtime-bound). It ensures list elements are converted to the list’s runtime element type before being added to the strongly typed runtime list, preventing IList.Add type mismatch failures (Fixes #9948).
Changes:
- Coerce (convert) parsed/deserialized list elements to the list element runtime type when the element GraphQL type is an input object.
- Add tests covering both literal parsing and JSON input deserialization for lists of input objects without runtime field binding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/HotChocolate/Core/src/Types/Types/InputParser.cs | Converts input-object list elements to the runtime element type before adding to the runtime list (both literal and JSON paths). |
| src/HotChocolate/Core/test/Types.Tests/Types/InputParserTests.cs | Adds regression tests for list-of-input-object coercion (literal + JSON). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall coverage in the Show a code coverage summary of the most impacted files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
Fixes #9948