DroneDeploy
Search…
Pagination
When a one-to-many relationship exists between two nodes, for example organization -> plans, we paginate the responses from the query. Forward, cursor based pagination is used, for more details see here.

Forward Pagination

The arguments for forward pagination are:
    first a non-negative integer representing the number of results
    after: the cursor of which the results will be after
The connection which is returned includes the following fields:
    pageInfo: which contains the fields hasNextPage and endCursor
    edges: which includes a list of edges. Each edge contains the cursor for that node and the node itself

Example:

For this example we will go through the organization link to plans.
Firstly we'll get the plans connection with the first two edges:
1
{
2
viewer{
3
username
4
organization {
5
plans(first: 2) {
6
pageInfo{
7
hasNextPage
8
endCursor
9
}
10
edges {
11
cursor
12
node {
13
name
14
}
15
}
16
}
17
18
}
19
}
20
}
Copied!
This returns:
1
{
2
"data": {
3
"viewer": {
4
"username": "[email protected]",
5
"organization": {
6
"plans": {
7
"pageInfo": {
8
"hasNextPage": true,
9
"endCursor": "YXJyYXljb25uZWN0aW9uOjE="
10
},
11
"edges": [
12
{
13
"cursor": "YXJyYXljb25uZWN0aW9uOjA=",
14
"node": {
15
"name": "Field Map"
16
}
17
},
18
{
19
"cursor": "YXJyYXljb25uZWN0aW9uOjE=",
20
"node": {
21
"name": "Downtown Map"
22
}
23
}
24
]
25
}
26
}
27
}
28
}
29
}
Copied!
You can see that hasNextPage is true so we know there are more items and the endCursor is set to the last item in the response. Two fetch the next page you simply update the query to include the after parameter for the connection:
1
{
2
viewer{
3
username
4
organization {
5
plans(first: 2, after:"YXJyYXljb25uZWN0aW9uOjE=") {
6
pageInfo{
7
hasNextPage
8
endCursor
9
}
10
edges {
11
cursor
12
node {
13
name
14
}
15
}
16
}
17
18
}
19
}
20
}
Copied!
This returns the data:
1
{
2
"data": {
3
"viewer": {
4
"username": "[email protected]",
5
"organization": {
6
"plans": {
7
"pageInfo": {
8
"hasNextPage": true,
9
"endCursor": "YXJyYXljb25uZWN0aW9uOjM="
10
},
11
"edges": [
12
{
13
"cursor": "YXJyYXljb25uZWN0aW9uOjI=",
14
"node": {
15
"name": "New map"
16
}
17
},
18
{
19
"cursor": "YXJyYXljb25uZWN0aW9uOjM=",
20
"node": {
21
"name": "Untitled Plan"
22
}
23
}
24
]
25
}
26
}
27
}
28
}
29
}
Copied!