Paginate Results

API v56.0 and later

GraphQL API returns the first 10 results of a query by default. Based on the GraphQL Cursor Connections Specification, the returned object is wrapped by the Connection object, which contains the node (account, for example) and totalCount objects. Additionally, the pageInfo object contains cursor information and if there are more results to return.

For more information about Connection and its types, see Query Objects: Pagination for more information.

The query results are as follows.

Paging uses the first and after arguments based on the Relay Record Connection, which follows the specification for Forward Pagination Arguments.

  • The first argument is the maximum number of records to fetch as part of your query.

  • The after argument is a cursor used to page through the result set. Omit the argument or provide a null value to start at the beginning of the result set. Use a returned cursor to continue paging through the result set from that cursor position. The after argument is typically set to the value of the endCursor field on the Relay Connection's PageInfo. If you want to page from a particular element in the result set, use the cursor field from a Relay Edge.

This example returns the next 5 results after the djE6OQ== end cursor from the previous example.

The query results are as follows.

The previous query is similar to the following SOQL statement.

LIMIT and OFFSET clauses can work for up to 2000 results only.

You can page through the child records on a queried parent record. Paging on the parent and children records at the same time isn't supported. The child relationships records in the response are paginated and include cursor and pagination information. Use the first argument to specify the number of records to return. The default is 10.

The query results are as follows.

The previous query is similar to the following SOQL statement.

The maximum number of child relationship records to return can be specified using the first argument. However, if supplying a cursor value to the after argument of a child relationship, then the parent Record must be limited to a single result. For example:

LIMIT Clause