Repository navigation
Description
Product
Hot Chocolate
Version
16,1,4
Link to minimal reproduction
Steps to reproduce
I use DynamicSchema with custom TypeModule class.
I found that input parameters not working when you declare array typ as input arguments.
It should be problem in deserelization...
What is expected?
I write down details in section "What is actually happening?"
What is actually happening?
In file InputParser.cs inside function
private IList ParseList(IValueNode resultValue, ListType type, Path path, int stack, bool defaults, IInputValueInfo? field)
line 127 (v16.1.4) you have source:
list.Add( ParseLiteralInternal( items[i], elementType, path.Append(i), stack, defaults, field));
In this case is problem because object list use runtime list type lin1 118:
var list = CreateList(type);
But Function ParseLiteralInternal return type Dictionary<string,object>.
And here a type conversion error occurs.
The lin 127 in file InputParser.cs should be fixed with addtional type conversation.
I prepared one posible solution:
var dict = ParseLiteralInternal(items[i],elementType,path.Append(i),stack,defaults,field);
dict = FormatValue(inputValueInfo, dict);
var value = ConvertValue(type.RuntimeType, dict, out var conversionException);
if (conversionException != null)
{
throw InvalidTypeConversion(type.RuntimeType, field, path, null, conversionException);
}
list.Add(value);
Can you applay this fix in your code. Thanks in advance.
P.S.: Reproduction link is link to library file InputParser.cs where is bug in version 16.1.3 in line 127.
I hope I was understandable even without reproduction example. If necessary, I can prepare reproduction code in advance.
Relevant log output
The value "System.Collections.Generic.Dictionary`2[System.String,System.Object]" is not of type "Framework.Entities.Link" and cannot be used in this generic collection. (Parameter 'value')
Stack trace:
at System.ThrowHelper.ThrowWrongValueTypeArgumentException[T](T value, Type targetType) in /_/src/runtime/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs:line 304
at System.Collections.Generic.List`1.System.Collections.IList.Add(Object item) in /_/src/runtime/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs:line 233
at HotChocolate.Types.InputParser.ParseList(IValueNode resultValue, ListType type, Path path, Int32 stack, Boolean defaults, IInputValueInfo field) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Types/InputParser.cs:line 127
at HotChocolate.Types.InputParser.ParseLiteralInternal(IValueNode value, IType type, Path path, Int32 stack, Boolean defaults, IInputValueInfo field) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Types/InputParser.cs:line 104
at HotChocolate.Types.InputParser.ParseLiteral(IValueNode value, IInputValueInfo field, Type targetType) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Types/InputParser.cs:line 53
at HotChocolate.Execution.Processing.MiddlewareContext.CoerceArgumentValue[T](ArgumentValue argument) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Execution/Processing/MiddlewareContext.Arguments.cs:line 97
at HotChocolate.Execution.Processing.MiddlewareContext.ArgumentValue[T](String name) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Execution/Processing/MiddlewareContext.Arguments.cs:line 25
at Framework.GraphQL.Schemas.Repository.RepositorySqlEntity`1.<Framework-GraphQL-Schemas-Repository-IRepositorySqlEntity-Add>d__7.MoveNext() in C:\Users\jk\Work\lab\Framework\GraphQL\Schema\Repository\Helpers\RepositorySqlEntity.cs:line 140
at Framework.GraphQL.Schemas.Repository.RepositorySchemaTypeModule.<>c__DisplayClass10_1.<<CreateTypesAsync>b__1>d.MoveNext() in C:\Users\jk\Work\lab\Framework\GraphQL\Schema\Repository\RepositorySchemaTypeModule.cs:line 104Additional context
No response
Activity