Skip to content

In *Connection types, the pageInfo.totalPages property is zero if the page index was too high #210

@TwilCynder

Description

@TwilCynder

When a paginated list (such as Event.sets), of a "Connection"-style type, is queried with a page number that is too high (which returns an empty list in the nodes property), the pageInfo.totalPages property will be zero. For example, if a sets list has 105 elements, and a query is made with perPage: 10, SetsConnection.pageInfo.totalPages will contain 11, if the page index is 1-11, but is it is 12 or higher, SetsConnection.pageInfo.totalPages will be zero.

A more concrete example :

Schema

query UserSets($slug: String!, $page: Int, $perPage: Int, $after: Timestamp) {
	user(slug: $slug){
    player {
      sets(page: $page, perPage: $perPage, filters : {
        updatedAfter: $after
      }) {
        pageInfo {
          totalPages
        }
        nodes {
          slots {
            entrant {
              participants {
                user {
                  slug
                }
              }
            }
          }
        }
      }
    }
  }
}

Variables 1

{
	"slug": "2863f841",
  "page": 10,
  "perPage": 100
}

Result 1

{
  "data": {
    "user": {
      "player": {
        "sets": {
          "pageInfo": {
            "totalPages": 10
          },
          "nodes": [

Variables 2

{
	"slug": "2863f841",
  "page": 11,
  "perPage": 100
}

Result 2

{
  "data": {
    "user": {
      "player": {
        "sets": {
          "pageInfo": {
            "totalPages": 0
          },
          "nodes": []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions