Understanding connections
Connections are collections that support pagination. They follow a consistent structure:Connection fields
edges: An array of edge objects, each containing anodeand acursornode: The actual data objectpageInfo: Information about the current page and available pageshasNextPage: Boolean indicating if more pages are availablehasPreviousPage: Boolean indicating if previous pages existstartCursor: Cursor for the first item in the current pageendCursor: Cursor for the last item in the current page
Forward pagination
Usefirst and after to page forward:
Backward pagination
Uselast and before to page backward:
Pagination limits
firstandlastmust be between 1 and 500- You must specify either
firstorlast, but not both - If you specify
first, you can optionally includeafter - If you specify
last, you can optionally includebefore
Example: paginating through all deals
Filtering with pagination
You can combine pagination with filters:Best practices
- Use appropriate page sizes - Don’t request more than you need, but avoid too many small requests
- Store cursors - Save
endCursorto resume pagination later - Handle empty results - Check if
edgesis empty - Respect rate limits - Don’t make excessive pagination requests
- Use
hasNextPage- Check this before making another request