Skip to content

Latest commit

 

History

History
83 lines (77 loc) · 2.2 KB

cursor_pagination.md

File metadata and controls

83 lines (77 loc) · 2.2 KB

Cursor Based Pagination

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: