You can pass in first
, last
, after
and before
GraphQL Documentation on Pagination
Example:
Query
{
Users(first: 10) {
totalCount,
pageInfo {
hasNextPage,
hasPreviousPage,
startCursor,
endCursor
},
edges {
cursor,
node {
name,
first_name
}
}
}
}
Response
{
"data": {
"Users": {
"totalCount": 3,
"pageInfo": {
"hasNextPage": false,
"hasPreviousPage": false,
"startCursor": "WwogIjIwMjEtMDItMTMgMjM6MjM6NTUuMjc4MDIzIgpd",
"endCursor": "WwogIjIwMjEtMDItMDIgMDg6MzU6MTIuODM2MzU5Igpd"
},
"edges": [
{
"cursor": "WwogIjIwMjEtMDItMTMgMjM6MjM6NTUuMjc4MDIzIgpd",
"node": {
"name": "[email protected]",
"first_name": "Test"
}
},
{
"cursor": "WwogIjIwMjEtMDItMDIgMDg6MzU6MTQuMDI2MDc3Igpd",
"node": {
"name": "Administrator",
"first_name": "Administrator"
}
},
{
"cursor": "WwogIjIwMjEtMDItMDIgMDg6MzU6MTIuODM2MzU5Igpd",
"node": {
"name": "Guest",
"first_name": "Guest"
}
}
]
}
}
}
If you want to implement the same in one of your Custom queries, please check out the following examples here: Custom & Nested Pagination
More Examples:
- Get Users with all the documents they
own
- Get Todo list sorted by assigned_user (owner) & status
- Sort Users by number of Roles they got have assigned