Skip to content
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

System.Text.Json.JsonException when parsing response from SendMutationAsync. #628

Open
sannidha opened this issue Mar 19, 2024 · 1 comment

Comments

@sannidha
Copy link

We have recently upgraded our project to .Net 7 and we have started seeing this issue. We are using version 6.0.2.
but the json response looked fine.
Response:
{"data":{"provisionSsoUser":{"user":{"id":"d48656b8-c5a2-42f4-be2b-62f5e647c90f"}}}}

Code as below:

 var client = new GraphQLHttpClient(
     x =>
     {
         x.EndPoint = _graphQlEndpoint;
         x.HttpMessageHandler = new LoggingHandler(new HttpClientHandler());
     },
     new DebugSerializer());
 client.HttpClient.DefaultRequestHeaders.Add("Authorization", $"PSK {_graphQlPsk}");

 var provisionSsoUserRequest = new GraphQLRequest
     {
         Query = GraphQl.ProvisionSsoUser,
         OperationName = "ProvisionSsoUser",
         Variables = new { input = new { email = "[email protected]", name = "FullName", cw1OrganizationCode = "Code" } }
     };


// Exception thrown at this line.
 var response = await client.SendMutationAsync(provisionSsoUserRequest, () => new { provisionSsoUser = new { user = new { id = Guid.Empty } } });

StackTrace as below:

System.Text.Json.JsonException: The converter 'GraphQL.Client.Serializer.SystemTextJson.ImmutableConverter' read too much or not enough. Path: $ | LineNumber: 0 | BytePositionInLine: 9.
at System.Text.Json.ThrowHelper.ThrowJsonException_SerializationConverterRead(JsonConverter converter)
at System.Text.Json.Serialization.JsonConverter1.VerifyRead(JsonTokenType tokenType, Int32 depth, Int64 bytesConsumed, Boolean isValueConverter, Utf8JsonReader& reader) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.Serialization.JsonConverter1.ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo, ReadStack& state)
at System.Text.Json.JsonSerializer.Read[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
at GraphQL.Client.Serializer.SystemTextJson.ImmutableConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in //src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs:line 68
at System.Text.Json.Serialization.Converters.CastingConverter2.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
at GraphQL.Client.Http.GraphQLHttpClient.SendHttpRequestAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken) in /
/src/GraphQL.Client/GraphQLHttpClient.cs:line 129
at GraphQL.Client.Http.GraphQLHttpClient.SendQueryAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken) in /_/src/GraphQL.Client/GraphQLHttpClient.cs:line 81

@rose-a
Copy link
Collaborator

rose-a commented Mar 20, 2024

propably related to #622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants