Skip to main content
The Pylon GraphQL API uses cursor-based pagination for collections. This guide shows you how to page through results using the connection pattern.

Understanding connections

Connections are collections that support pagination. They follow a consistent structure:

Connection fields

  • edges: An array of edge objects, each containing a node and a cursor
  • node: The actual data object
  • pageInfo: Information about the current page and available pages
    • hasNextPage: Boolean indicating if more pages are available
    • hasPreviousPage: Boolean indicating if previous pages exist
    • startCursor: Cursor for the first item in the current page
    • endCursor: Cursor for the last item in the current page

Forward pagination

Use first and after to page forward:
Variables for first page:
Variables for next page:

Backward pagination

Use last and before to page backward:

Pagination limits

  • first and last must be between 1 and 500
  • You must specify either first or last, but not both
  • If you specify first, you can optionally include after
  • If you specify last, you can optionally include before

Example: paginating through all deals

Sorting with pagination

You can combine pagination with a sort direction:

Best practices

  1. Use appropriate page sizes - Don’t request more than you need, but avoid too many small requests
  2. Store cursors - Save endCursor to resume pagination later
  3. Handle empty results - Check if edges is empty
  4. Respect rate limits - Don’t make excessive pagination requests
  5. Use hasNextPage - Check this before making another request

Common patterns

Fetching a specific page

If you need to jump to a specific page, you’ll need to paginate from the beginning or store cursors:

Counting total items

The connection pattern doesn’t provide a total count. If you need a count, you’ll need to paginate through all items or use a separate query if available.