Skip to main content

Pagination

Refersion GraphQL currently supports offset-based pagination, which lets you offset the start of each page by the number specified.

Let's say you'd like to pull a list of all your May 2018 conversions, and there are 800 results in total. In order to get all 800 results, you'd need to make a total of 4 requests (since each request returns a maximum of 200 results) using offsets.

First request

Sample query:

{
conversions(created_from: 1525132800 created_to: 1527202238 first: 200) {
affiliate {
name
email
}
total
commission_total
currency
created
}
}

Sent as:

{"query": "{ conversions(created_from: 1525132800 created_to: 1527202238 first: 200) { affiliate { name email } total commission_total currency created } }"}

Second request

The query is identical apart from offset, which fetches the next 200 results starting from record #201:

{"query": "{ conversions(created_from: 1525132800 created_to: 1527202238 first: 200 offset: 200) { affiliate { name email } total commission_total currency created } }"}

Third request

offset: 400 gets you records #401–600:

{"query": "{ conversions(created_from: 1525132800 created_to: 1527202238 first: 200 offset: 400) { affiliate { name email } total commission_total currency created } }"}

Fourth request

offset: 600 gets you records #601–800:

{"query": "{ conversions(created_from: 1525132800 created_to: 1527202238 first: 200 offset: 600) { affiliate { name email } total commission_total currency created } }"}

Repeat the above for larger number of results until you get all the data returned.

Total Pagination Results

Deprecated

pageInfo is deprecated and no longer returns accurate results. Page with first and offset as shown above, or with before and after — see PageInfo and Filtering and Sorting.

It is possible to select the total number of results that can be retrieved using a GraphQL query by adding a pageInfo section to your request. This can be helpful for determining when you have requested all possible pages for a query.

Please note: Queries with multiple sub-queries and filters may return an incorrect number for the total results count within the pageInfo query. We recommend keeping queries simple for the best experience.

Sample query:

{
conversions(created_from: 1525132800 first: 200 offset: 600) {
affiliate {
name
email
}
total
commission_total
currency
created
}
pageInfo {
total_results {
conversions
}
}
}

Sent as:

{"query": "{ conversions(created_from: 1525132800 first: 200 offset: 600) { affiliate { name email } total commission_total currency created } pageInfo { total_results { conversions } } }"}

Sample response:

{
"data": {
"conversions": [
{
"affiliate": {
"name": "ABC",
"email": "[email protected]"
},
"total": "24.00",
"commission_total": "4.80",
"currency": "USD",
"created": "1526674258"
},
...
],
"pageInfo": {
"total_results": {
"conversions": [
"800",
"This will no longer return accurate results."
]
}
}
}
}