Full Sync Example
Full sync
= the entire sync process with the retrieval of all data in batches, as well as how to useentity changes
to maintain all the data retrieved.
Scenario -Fetch Invoice Data
- Make sure to look up the specific entityType that you should sync, in our example we show you how to sync ledgerNote data.
- We currently support the "Subscription-entities" towards this use-case scenario, to read more about the current "Subscription-entities" please visit our GQL-endpoint
here.
- Fetch the latest
lastLocalId
, save it, then use it after thefull sync
process.
Start the Synchronization
- Use
lastId
for pagination, i.e., the lastId/page serves as thelastId
for the next page. - The entire process flows through steps a-b-c.
- In our example we filter against
replaced
,removed
anddraft
statuses to only fetch current data. - Extend queries
a
b
orc
based on your data preferences.
Use the Latest localId
(which you saved earlier) from Entity Changes
- Use the latest
localId
as the starting point (e.g.,lastLocalId: LatestFetchedLocalID
). - In the usecase
enitity change
you can get further details. - Check for
pruned = true
. Ifpruned = true
is encountered, you must re-run the entire process. Read more aboutpruned
.
Populate a "Resync" Based on Changed IDs
- Use
ledgerNotesById
to fetch updated details for entityId's that have changed. - Filter the entityId's to ensure they are distinct (removing any duplicate IDs).