-
-
Notifications
You must be signed in to change notification settings - Fork 803
fix(PageConnection): fallback to 0, not -1 on empty pages #9412
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
base: main
Are you sure you want to change the base?
Changes from all commits
911e561
6a34df9
865c53c
1dd1020
d3fbe72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,5 +76,6 @@ public override IReadOnlyList<PageEdge<TNode>>? Edges | |
| /// Identifies the total count of items in the connection. | ||
| /// </summary> | ||
| [GraphQLDescription("Identifies the total count of items in the connection.")] | ||
| public int TotalCount => _page.TotalCount ?? -1; | ||
| public int TotalCount => | ||
| _page.TotalCount ?? throw new GraphQLException("Total count is not available for this connection."); | ||
|
Comment on lines
+79
to
+80
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting
ValueCursorPage<T>.Emptyto havetotalCount = 0changes the public behavior ofPage<T>.Empty.TotalCountfromnull(unknown) to a concrete value (known 0). SincePage<T>.Emptyis returned in paging code paths when no items are fetched (e.g.PagingQueryableExtensions.ToPageAsyncreturnsPage<T>.Emptywhenbuilder.Count == 0, even when the underlying dataset might not be empty), this can causeTotalCountto be reported as 0 when it’s actually unknown/non-zero. Consider keepingTotalCountasnullonEmptyand handling any GraphQL-facing fallback (0 vs -1) at the connection layer instead.