Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ValueCursorPage(
/// <summary>
/// An empty page.
/// </summary>
public static new ValueCursorPage<T> Empty { get; } = new([], false, false, _ => string.Empty);
public static new ValueCursorPage<T> Empty { get; } = new([], false, false, _ => string.Empty, 0);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting ValueCursorPage<T>.Empty to have totalCount = 0 changes the public behavior of Page<T>.Empty.TotalCount from null (unknown) to a concrete value (known 0). Since Page<T>.Empty is returned in paging code paths when no items are fetched (e.g. PagingQueryableExtensions.ToPageAsync returns Page<T>.Empty when builder.Count == 0, even when the underlying dataset might not be empty), this can cause TotalCount to be reported as 0 when it’s actually unknown/non-zero. Consider keeping TotalCount as null on Empty and handling any GraphQL-facing fallback (0 vs -1) at the connection layer instead.

Suggested change
public static new ValueCursorPage<T> Empty { get; } = new([], false, false, _ => string.Empty, 0);
public static new ValueCursorPage<T> Empty { get; } = new([], false, false, _ => string.Empty);

Copilot uses AI. Check for mistakes.

protected override string CreateCursor(int index, int offset, int pageIndex, int totalCount)
=> _createCursor(new EdgeEntry<T>(Entries[index].Item, offset, pageIndex, totalCount));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation no longer “falls back to 0” when the total count is unavailable; it now throws a GraphQLException when _page.TotalCount is null. That’s a behavior change vs both the PR description/title and existing Page->Connection conversion which uses page.TotalCount ?? 0 (e.g. HotChocolatePaginationResultExtensions.CreateConnection: page.TotalCount ?? 0). Consider returning 0 (or keeping the existing sentinel) instead of throwing, or make the GraphQL field nullable if “not available” must be represented explicitly.

Copilot uses AI. Check for mistakes.
}
Loading