Skip to content

Relative Cursor: ForwardCursors field does not contain last page #8273

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

Closed
nickodei opened this issue May 7, 2025 · 0 comments · Fixed by #8295
Closed

Relative Cursor: ForwardCursors field does not contain last page #8273

nickodei opened this issue May 7, 2025 · 0 comments · Fixed by #8295
Assignees
Milestone

Comments

@nickodei
Copy link

nickodei commented May 7, 2025

Product

Green Donut

Version

15.1.3

Link to minimal reproduction

not needed

Steps to reproduce

Using a query with a relative cursor, where you fetch with first an amount of items that is not divisible by the totalCount to an integer.

What is expected?

You get a cursor to the last page (here its page 2 because 12 / 10 > 1) when fetching the first 10 elements:

query(first: 10) { ... }

{
  "data": {
    "query": {
      "pageInfo": {
        "hasNextPage": true,
        "hasPreviousPage": false,
        "backwardCursors": [],
        "forwardCursors": [
          {
            "page": 2,
            "cursor": "base64 encoded id"
          }
        ]
      },
      "totalCount": 12
    }
  }
}

What is actually happening?

You get an empty list for the forwardCursors:

{
  "data": {
    "query": {
      "pageInfo": {
        "hasNextPage": true,
        "hasPreviousPage": false,
        "backwardCursors": [],
        "forwardCursors": []
      },
      "totalCount": 12
    }
  }
}

Relevant log output

Additional context

This happens because we divide the TotalCount by the RequestedSize and we get an integer. We need to round up when there is a residual to get a cursor to the last items. Using Math.Ceiling or something like that.

var totalPages = (page.TotalCount ?? 0) / (page.RequestedSize ?? 10);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants