Skip to content

Fix total count for empty pages - #10113

Merged
michaelstaib merged 6 commits into
mainfrom
mst/page-empt
Jul 14, 2026
Merged

michaelstaib merged 6 commits into
mainfrom
mst/page-empt

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts empty-page handling so that TotalCount is correct for empty result pages, distinguishing between “known empty” (TotalCount = 0) and “empty but total count unknown” (TotalCount = null).

Changes:

  • Redefines Page<T>.Empty (via ValueCursorPage<T>.Empty) to represent a known-empty page with TotalCount = 0.
  • Updates EF paging helpers to preserve totalCount (including non-zero counts) even when the returned page has no items.
  • Updates and adds tests to cover TotalCount behavior for empty pages and for “unknown total count” empty pages.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/HotChocolate/Core/test/Types.CursorPagination.Tests/PageConnectionTests.cs Updates test setup to ensure “unknown total count” uses an empty page with TotalCount = null, while “known empty” uses Page.Empty.
src/GreenDonut/test/GreenDonut.Data.Tests/PageTests.cs Adds coverage asserting Page.Empty.TotalCount == 0.
src/GreenDonut/src/GreenDonut.Data.Primitives/ValueCursorPage.cs Changes ValueCursorPage.Empty to include totalCount = 0, affecting Page<T>.Empty.
src/GreenDonut/src/GreenDonut.Data.EntityFramework/Extensions/PagingQueryableExtensions.cs Ensures empty pages returned from EF paging preserve totalCount instead of defaulting to Page.Empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (3/3)

File Covered Changed Patch %
…/Extensions/PagingQueryableExtensions.cs 2 2 100.0% 🟢
…/GreenDonut/src/GreenDonut.Data.Primitives/ValueCursorPage.cs 1 1 100.0% 🟢

Project coverage: 53.7% (230653/429484 lines)

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ michaelstaib
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants