Choosing a page
You can use pagination to return only a certain amount of results at a time. Here is how you can use it :
query{
Invoices(
page:3
page_size:10
){
edges{
node{
id
}
}
}
}
- page is the page number: you can increment it to get the next batch of results. It is set as 1 by default.
- page_size is the amount of results you get at a time. It is set at 50 by default, and must be set between 1 and 250.
You can choose to only pass one of these arguments at a time, and you can pass other fields and arguments like you would for any other query.
Keeping track of the pages
If you want to paginate your results, you need to know how many pages are possible in total, meaning you also want to know how many results there are in total. This is done by asking for the totalCount:
query{
Invoices(
page:3
page_size:10
){
totalCount
edges{
node{
id
}
}
}
}
You might have noticed the totalCount field passed outside of the edges sub-results. This returns the total amount of results that the query can fetch, regardless of pagination, to help you keep track of your page count.
For now, the totalCount field can only be called on the main query (here Invoices) if the query uses the edges structure. Using the totalCount field on subqueries will only return NULL.