Skip to content

Commit d54ebdd

Browse files
committed
Fix bug resulting in incorrect Exceptions when automatically enumerating (as IAsyncEnumerable) Connection Pages when a request returns with no results (NextPage = false & EndCursor = null).
1 parent 45f4c75 commit d54ebdd

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

FlurlGraphQL/FlurlGraphQL.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<!--NOTE: Just as with the base Flurl.Http.Newtonsoft library and Microsofts recommendation we now support net6 for the latest projects, but also netstandard2.1 which has proper Async streaming support,
55
in addition to netstandard2.0 + net461 for legacy support (because netstandard2.0 it had API compatibility issues prior to .NET Framework 4.7.x -->
66
<TargetFrameworks>net461;netstandard2.0;netstandard2.1;net6.0;</TargetFrameworks>
7-
<Version>2.0.1</Version>
8-
<AssemblyVersion>2.0.1</AssemblyVersion>
9-
<FileVersion>2.0.1</FileVersion>
7+
<Version>2.0.2</Version>
8+
<AssemblyVersion>2.0.2</AssemblyVersion>
9+
<FileVersion>2.0.2</FileVersion>
1010
<Authors>BBernard / CajunCoding</Authors>
1111
<Company>CajunCoding</Company>
1212
<Description>GraphQL client extensions for Flurl.Http -- lightweight, simplified, asynchronous, fluent GraphQL client API extensions for the amazing Flurl Http library!</Description>
@@ -17,9 +17,10 @@
1717
<RepositoryUrl>https://github.com/cajuncoding/FlurlGraphQL</RepositoryUrl>
1818
<PackageReleaseNotes>
1919
Release Notes:
20-
- Fix issue with incorrect deserialization when using wrapper convenience class GraphQLEdge&lt;T&gt;.
20+
- Fix bug resulting in incorrect Exceptions when automatically enumerating (as IAsyncEnumerable) Connection Pages when a request returns with no results (NextPage = false & EndCursor = null).
2121

2222
Prior Release Notes:
23+
- Fix issue with incorrect deserialization when using wrapper convenience class GraphQLEdge&lt;T&gt;.
2324
- Implement full support for Flurl v4.0+
2425
- Completely rewritten Json processing engine to now support both System.Text.Json &amp; Newtonsoft.Json.
2526
- System.Text.Json processing with Json transformation strategy is now ~10X faster than the original Newtonsoft.Json processing.

FlurlGraphQL/FlurlGraphQL/FlurlGraphQLResponseExtensions.Internal.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ Task<IFlurlGraphQLResponse> NextIterationResponseTask
7979

8080
var originalGraphQLRequest = flurlGraphQLResponse.GraphQLRequest;
8181

82-
//If there is another page then Update our Variables and request the NEXT Page Asynchronously;
82+
//If there is another page then Update our Variables and request the NEXT Page Asynchronously,
8383
// otherwise set our iteration to null to stop processing!
84-
var iterationResponseTask = !hasNextPage
85-
? null
86-
: originalGraphQLRequest
84+
var iterationResponseTask = hasNextPage
85+
? originalGraphQLRequest
8786
.SetGraphQLVariable(GraphQLConnectionArgs.After, endCursor)
88-
.PostGraphQLQueryAsync(cancellationToken);
87+
.PostGraphQLQueryAsync(cancellationToken)
88+
: null;
8989

9090
//Update our tracking endCursor to the new one we recieved for the next iteration...
9191
return (pageResult, endCursor, iterationResponseTask);
@@ -136,7 +136,7 @@ Task<IFlurlGraphQLResponse> NextIterationResponseTask
136136
}
137137

138138
internal static (bool HasNextPage, string EndCursor) AssertCursorPageIsValidForEnumeration(
139-
IGraphQLCursorPageInfo pageInfo,
139+
IGraphQLCursorPageInfo pageInfo,
140140
IFlurlGraphQLResponseProcessor graphqlResponseProcessor,
141141
FlurlGraphQLResponse flurlGraphQLResponse,
142142
string priorEndCursor
@@ -148,10 +148,11 @@ string priorEndCursor
148148
bool? hasNextPageFlag = pageInfo.HasNextPage;
149149
string endCursor = pageInfo.EndCursor;
150150

151-
if (hasNextPageFlag == null || endCursor == null)
151+
if (hasNextPageFlag == null || (hasNextPageFlag == true && endCursor == null))
152152
throw NewGraphQLException(graphqlResponseProcessor, flurlGraphQLResponse,
153153
"Unable to enumerate all pages because the pageInfo.hasNextPage and/or the pageInfo.endCursor values are not available in the GraphQL query response.");
154-
else if (endCursor == priorEndCursor)
154+
155+
if (endCursor == priorEndCursor)
155156
throw NewGraphQLException(graphqlResponseProcessor, flurlGraphQLResponse,
156157
"Unable to enumerate all pages because the pageInfo.endCursor is returning the same value. Check that the query is correct and that it correctly implements the (after:$after) variable.");
157158

0 commit comments

Comments
 (0)