graphql-dotnet / graphql-dotnet/graphql-client

Exception for empty response body

Open
#378 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Hello,

I am trying to build a client for a very basic GraphQL request. This works for most of the response types, but the server sends 204 and 504 responses for specific scenarios, along with an empty response body. When this happens I get a NullReferenceException with the following stacktrace:

```
at GraphQL.Client.Http.GraphQLHttpResponse`1..ctor(GraphQLResponse`1 response, HttpResponseHeaders responseHeaders, HttpStatusCode statusCode)
at GraphQL.Client.Http.GraphQLResponseExtensions.ToGraphQLHttpResponse[T](GraphQLResponse`1 response, HttpResponseHeaders responseHeaders, HttpStatusCode statusCode)
at GraphQL.Client.Http.GraphQLHttpClient.d__28`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at GraphQL.Client.Http.GraphQLHttpClient.d__23`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Application.Providers.Services.GqlApi.d__18.MoveNext() in D:\tfs\codebase\..\GqlApi.cs:line 97

```
The normal response is some JSON object. Is there any way to just get back the status and null for the object data?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.