One query for Pagination


#1

I am trying to use pagination with the following query:

{
  organization(login:"organization_name") {
    members(first: 100, after: "") {
      totalCount
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        login
        name
      }
    }
  }
}

I want to get the first page, but I get an INVALID_CURSOR_ARGUMENTS error. Is there specific first page cursor that I should send, or do I have to have a separate query without the after to get the first page?


#2

If you want first page, instead of sending an empty string as the after cursor value, just omit it:

members(first: 100) { ... }

If you’re using a variable, you can set it to null:

members(first: 100, after: $membersCursor) { ... }

{
  "membersCursor": null
}

#3

Wow, that was incredibly simple. Thank you for answering all of my newbie questions. :smile: