Pagination

In this guide, we will look at how to work with paginated responses when querying the Finite State API. Querying for ALL the results without using pagination can lead to performance issues and timeouts.

after

To paginate, query the _cursor field and use it as the value for the after argument to retrieve the next page.

first

The number of items to include in the result. If omitted, all remaining items will be included (which can cause performance problems on large collections). This is effectively the page size if used with the after argument.

skip

The number of items in the list or collection to skip. Is applied after the after argument if both are specified.

Example

This example gets the first page or results with a page size of 5.

query AllFindingsPaginated($after: String, $first: Int) {
  allFindings(after: $after, first: $first) {
    id
    title
    _cursor
  }
}

This query gets the second page of results by taking the _cursor from the last item returned from the previous query. Note, the only difference is the after variable.

query AllFindingsPaginated($after: String, $first: Int) {
  allFindings(after: $after, first: $first) {
    id
    title
    _cursor
  }
}