When designing integrations the concern should be on only pulling/pushing data that is necessary, Xledger's GraphQL API offers rich filtering capabilities to avoid pulling too much unnecessary data. However, in some cases large datasets will need to be pulled from GraphQL. For example with dealing with historical reporting or reconciliations.
Xledger's API has a limit of 10000 records per query, should this be insufficient or cause timeouts, cursor can be used.
There two main ways to use cursor pagination (see attached Postman collection for code) :
LIFO
LIFO (Last In First Out) will let you pull data from the most recent to the least recent, this is useful for getting data up to a certain point (for example last years worth of data when used with filters). To do so use the following to initialize the result.
Query :
using the last qualifier will pull the last modified customers, each records will have a cursor attached (in most cases the dbId)
Response :
The response will inform of two things :
- The last cursor to use in the next query
- If another query is necessary thanks to the hasPreviousPage boolean
The next queries will then look like this (updating the cursor at each iteration)
FIFO
FIFO (First In First Out) will let you pull data from the least recent to the most recent, this is useful to make sure all existing records are returned. To do so use the following to initialize the result.
Query :
using the first qualifier will pull the first modified customers, each records will have a cursor attached (in most cases the dbId)
Response :
The response will inform of two things :
- The last cursor to use in the next query
- If another query is necessary thanks to the hasNextPage boolean
The next queries will then look like this (updating the cursor at each iteration)