Full Sync Example
Full sync= the entire sync process with the retrieval of all data in batches, as well as how to useentity changesto 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 syncprocess.
Start the Synchronization
- Use
lastIdfor pagination, i.e., the lastId/page serves as thelastIdfor the next page. - The entire process flows through steps a-b-c.
- In our example we filter against
replaced,removedanddraftstatuses to only fetch current data. - Extend queries
aborcbased on your data preferences.
Use the Latest localId (which you saved earlier) from Entity Changes
- Use the latest
localIdas the starting point (e.g.,lastLocalId: LatestFetchedLocalID). - In the usecase
enitity changeyou can get further details. - Check for
pruned = true. Ifpruned = trueis encountered, you must re-run the entire process. Read more aboutpruned.
Populate a "Resync" Based on Changed IDs
- Use
ledgerNotesByIdto fetch updated details for entityId's that have changed. - Filter the entityId's to ensure they are distinct (removing any duplicate IDs).