Pagination

How to page through IXO Blocksync GraphQL results: the default page size, the first, last, after and before arguments, pageInfo, and the errors to handle.

This page explains how the IXO Blocksync GraphQL API splits large result sets into pages, and how you move through them with cursors. Use it when a query returns more records than you want in one response.

After reading it, you can request a page of a chosen size, fetch the next or the previous page, and tell when there is no more data.

Default pagination

The IXO Blocksync GraphQL API uses a default pagination value of 10 items across all queries.

Pagination parameters

ArgumentWhat it does
firstDefines the number of records to return in each query.
lastDefines the number of records to return, starting from the end of the dataset.
afterCursor to indicate the point in the dataset from which to continue fetching results.
beforeCursor to navigate backward from a specific point in the dataset.

first

query {
  entities(first: 50) {
    edges {
      node {
        id
        name
      }
    }
  }
}

last

query {
  entities(last: 10) {
    edges {
      node {
        id
        name
      }
    }
  }
}

after

query {
  entities(first: 20, after: "YXJyYXljb25uZWN0aW9uOjEw") {
    edges {
      node {
        id
        name
      }
    }
  }
}

before

query {
  entities(last: 10, before: "YXJyYXljb25uZWN0aW9uOjIw") {
    edges {
      node {
        id
        name
      }
    }
  }
}

Response structure

A paginated response includes metadata for navigation:

{
  "data": {
    "entities": {
      "edges": [
        {
          "node": {
            "id": "did:ixo:entity:001",
            "name": "Entity One"
          }
        }
      ],
      "pageInfo": {
        "endCursor": "YXJyYXljb25uZWN0aW9uOjIw",
        "hasNextPage": true
      }
    }
  }
}

Response fields

FieldMeaning
edgesArray of results
pageInfo.endCursorReference point for next results
pageInfo.hasNextPageIndicates more data availability

Best practices

PracticeWhat to do
Set reasonable limitsUse 20-100 items per query for optimal performance.
Handle end of dataCheck hasNextPage to determine if more data is available.
Avoid hardcodingUse cursor values from responses. Do not hardcode them.
Monitor rate limitsImplement rate limiting strategies to avoid 429 errors.

Where it suits your application, cache paginated results on the client.

Error handling

ErrorCause and response
400 Bad RequestOccurs with invalid cursor values. Always use cursors from previous responses.
429 Too Many RequestsImplement retry logic with exponential backoff when rate limits are reached.