Skip to Content

PageInfo

Information about pagination in a connection.

Type Definition

type PageInfo { hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String endCursor: String }

Fields

FieldTypeNullabilityDescriptionRelationship
hasNextPageBooleanNon-nullIndicates if there are more pages to fetch.Scalar
hasPreviousPageBooleanNon-nullIndicates if there are previous pages to go back to.Scalar
startCursorStringNullableThe cursor corresponding to the first node in the edges list.Scalar
endCursorStringNullableThe cursor corresponding to the last node in the edges list.Scalar

Relationships

The PageInfo type is used to provide pagination metadata for connection objects. It does not directly relate to other object types but is embedded within connection types such as:

  • PreviousPriceConnection.pageInfo
  • ProductConnection.pageInfo

These connections use PageInfo to inform clients about the pagination state, enabling efficient traversal of paged data sets.

Usage Examples

Basic Query

{ productConnection(first: 5) { pageInfo { hasNextPage hasPreviousPage startCursor endCursor } edges { node { id title } } } }

Field Selection

{ previousPriceConnection(last: 10) { pageInfo { hasNextPage startCursor } edges { node { price effectiveDate } } } }

Nested Queries

{ productConnection(first: 3) { pageInfo { hasNextPage hasPreviousPage startCursor endCursor } edges { cursor node { id title previousPriceConnection(last: 2) { pageInfo { hasNextPage endCursor } edges { node { price effectiveDate } } } } } } }

Filtering and Sorting

The PageInfo object itself does not support filtering or sorting, but it is used alongside connection queries that do. For example, to paginate through products sorted by creation date:

{ productConnection(first: 5, sortKey: CREATED_AT, reverse: true) { pageInfo { hasNextPage endCursor } edges { cursor node { id title createdAt } } } }

To fetch the next page using the cursor:

{ productConnection(first: 5, after: "cursor-value") { pageInfo { hasNextPage endCursor } edges { cursor node { id title } } } }

Implements

The PageInfo type does not implement any interfaces.

Connections

PageInfo is a subfield of connection types that follow the Relay Cursor Connections Specification, providing pagination metadata for:

  • PreviousPriceConnection
  • ProductConnection

These connections contain edges and pageInfo fields to enable cursor-based pagination.

  • Boolean! — The non-nullable scalar type used for hasNextPage and hasPreviousPage.
  • String — The scalar type used for cursor fields startCursor and endCursor.

Best Practices

  • Always request pageInfo when querying connection fields to handle pagination effectively.
  • Use hasNextPage and hasPreviousPage to determine if additional pages exist before making further requests.
  • Use startCursor and endCursor to paginate forward or backward through results using after and before arguments.
  • Limit the number of items per page to optimize performance and reduce payload size.
  • Combine pagination with sorting and filtering on connection queries for efficient data retrieval.

Notes

  • The PageInfo object provides essential information for cursor-based pagination but does not itself support filtering or sorting.
  • Cursors (startCursor and endCursor) are opaque strings that should be treated as tokens for pagination and not parsed or modified.
  • Pagination using PageInfo helps improve API performance by enabling incremental data fetching.
  • The API currently requires no authentication; however, this may change in future versions. Always handle errors gracefully in your client applications.
Last updated on