Develop Secure Code
Pagination
Children and Parent Relationships
Page through your query results and control the number of results you want to return each time.
The GraphQL wire adapter follows the GraphQL Cursor Connections Specification for pagination.
To specify the number of records to return, use the first argument. The default number is 10.
If hasNextPage is true, you can supply the value of endCursor to the after argument of a subsequent query to request the next page of results.
Backward pagination arguments last and before are currently not supported.
Note
To create a query with cursor information, use the query parameter of the GraphQL wire adapter.
1query operationName {
2 uiapi {
3 query {
4 Account (first: 8, after: "endCursorFromPreviousQuery") {
5 edges {
6 node {
7 Id
8 Name {
9 value
10 }
11 }
12 }
13 totalCount
14 pageInfo {
15 endCursor
16 startCursor
17 hasNextPage
18 hasPreviousPage
19 }
20 }
21 }
22 }
23}This example response contains cursor information.
1{
2 "data": {
3 "uiapi": {
4 "query": {
5 "Account": {
6 "edges": [
7 {
8 "node": {
9 "Id": "001RM000005ZclBYAS",
10 "Name": {
11 "value": "GenePoint"
12 }
13 }
14 },
15 {
16 "node": {
17 "Id": "001RM000005Zcl6YAC",
18 "Name": {
19 "value": "United Oil"
20 }
21 }
22 }
23 ], // 6 more node objects here removed for brevity
24 "totalCount": 8,
25 "pageInfo": {
26 "endCursor": "djE6Nw==",
27 "startCursor": "djE6MA==",
28 "hasNextPage": true,
29 "hasPreviousPage": false
30 }
31 }
32 }
33 }
34 },
35 "errors": []
36}The lwc-recipes repo has many GraphQL API examples. Look for components that start with graphql, such as graphqlPagination.
Tip
See Also