Skip to content

Commit 9e431d6

Browse files
committed
Fix null reference issue in GraphQL/Request Error handling of HttpStatusCode.
1 parent 1cde15c commit 9e431d6

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

FlurlGraphQL.Querying/Flurl/FlurlGraphQLRequest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,14 @@ protected async Task<FlurlGraphQLResponse> ExecuteRequestWithExceptionHandling(F
356356
}
357357
catch (FlurlHttpException httpException)
358358
{
359-
var httpStatusCode = (HttpStatusCode)httpException.StatusCode;
359+
var httpStatusCode = (HttpStatusCode?)httpException?.StatusCode;
360360
var errorContent = await httpException.GetResponseStringSafelyAsync().ConfigureAwait(false);
361361

362-
if (httpStatusCode == HttpStatusCode.BadRequest)
362+
if (httpStatusCode is HttpStatusCode.BadRequest)
363363
throw new FlurlGraphQLException(
364364
$"[{(int)HttpStatusCode.BadRequest}-{HttpStatusCode.BadRequest}] The GraphQL server returned a bad request response for the query."
365365
+ " This is likely caused by a malformed, or non-parsable query; validate the query syntax, operation name, arguments, etc."
366-
+ " to ensure that the query is valid.", this.GraphQLQuery, errorContent, httpStatusCode, httpException
366+
+ " to ensure that the query is valid.", this.GraphQLQuery, errorContent, httpStatusCode.Value, httpException
367367
);
368368
else
369369
throw;

FlurlGraphQL.Querying/FlurlGraphQL.Querying.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5-
<Version>1.3.0</Version>
6-
<AssemblyVersion>1.3.0</AssemblyVersion>
7-
<FileVersion>1.3.0</FileVersion>
5+
<Version>1.3.1</Version>
6+
<AssemblyVersion>1.3.1</AssemblyVersion>
7+
<FileVersion>1.3.1</FileVersion>
88
<Authors>BBernard / CajunCoding</Authors>
99
<Company>CajunCoding</Company>
1010
<Description>GraphQL client extensions for Flurl.Http -- lightweight, simplified, asynchronous, fluent GraphQL client API extensions for the amazing Flurl Http library!</Description>
@@ -14,6 +14,7 @@
1414
<RepositoryUrl>https://github.com/cajuncoding/FlurlGraphQL</RepositoryUrl>
1515
<PackageReleaseNotes>
1616
Release Notes:
17+
- Full Null reference issue in GraphQL/Request Error handling of HttpStatusCode.
1718
- Added better support for Mutation handling so that single payload (per Mutation convention best practices) can be returned easily via ReceiveGraphQLMutationResult;
1819
this eliminates the need to use ReceiveGraphQLRawJsonResponse for dynamic Mutation response handling.
1920
- Fixed bug to ensure Errors are returned on IGraphQLQueryResults when possible (not available on Batch Queries).

0 commit comments

Comments
 (0)