-
-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
Description
Describe the bug
When calling ReadBody in the RequestReader if the body includes some variables then an exception is thrown.
The exception that is thrown is:
System.Text.Json.JsonException : The JSON value could not be converted to System.Collections.Generic.IEnumerable`1[Newtonsoft.Json.Linq.JToken]. Path: $.variables | LineNumber: 0 | BytePositionInLine: 82.
Stack Trace:
ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
JsonPropertyInfoNotNullable`4.OnReadEnumerable(ReadStack& state, Utf8JsonReader& reader)
JsonPropertyInfo.ReadEnumerable(JsonTokenType tokenType, ReadStack& state, Utf8JsonReader& reader)
JsonPropertyInfo.Read(JsonTokenType tokenType, ReadStack& state, Utf8JsonReader& reader)
JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
JsonSerializer.ReadCore(JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan`1 buffer, JsonSerializerOptions options, ReadStack& readStack)
JsonSerializer.ReadAsync[TValue](Stream utf8Json, Type returnType, JsonSerializerOptions options, CancellationToken cancellationToken)
RequestReader.ReadBody(Stream stream, CancellationToken cancellation) line 55
RequestReaderTests.Parse(String chars) line 46
RequestReaderTests.Parse(String chars) line 47
--- End of stack trace from previous location where exception was thrown ---
Minimal Repro
The issue can be reproduced with the following test:
[Fact]
public Task ParsingWithVariables()
{
return Parse("{\"query\":\"{\\n noAttachment\\n {\\n argument\\n }\\n}\",\"variables\":{\"key\":\"value\"},\"operationName\":\"theOperation\"}");
}