index/functions/addCursorToPagination.md
addCursorToPagination(
baseOptions,cursor):BasePaginationOptions
Conditionally include a cursor in pagination options
Useful for the common pattern of optionally including cursor-based pagination.
base options pagination
Parameters
| Parameter | Type | Description |
|---|---|---|
baseOptions | BasePaginationOptions | Base pagination options |
cursor | string | undefined | Cursor token (may be undefined) |
base options pagination
Returns
Options with cursor only if cursor is defined
base pagination options
Example
const nextPageOptions = addCursorToPagination(
{ pageSize: 50 },
pageInfo.endCursor ?? undefined
);
// Result: { pageSize: 50, cursor: 'abc123' } or { pageSize: 50 }
// depending on whether endCursor is set
Since
8.0.0