Introduction to Data Synchronization
@graphback/datasync package consists of the Data Synchronization Schema plugin and compatible data sources, provides out of the box Data Synchronization strategies for GraphQL clients with offline functionality e.g. Offix.
Currently this plugin only supports MongoDB data sources, with support for other kinds of data sources coming in a future release.
@graphback/datasync package is meant to be naturally extend Offix with a GraphQLCRUD compliant API:
- Fetch data that was changed based on the client side timestamp
- Ensure data consistency using timestamp provided
It achieves this by:
- Providing Delta Queries: Delta queries can be used by GraphQL clients to refresh changes in data between periods of connectivity outages.
- Providing server-side Conflict Resolution capabilities: For mutations that are applied offline, this provides the server with the ability to resolve conflicts between server and client.
The Graphback Data Synchronization package provides schema plugins as well as data sources for all supported data synchronization features.
Add annotations to your data models:
The preferred and simpest way to add data sync functionality is to use the
createDataSyncAPI function which wraps
Alternatively, you can use the default
buildGraphbackAPI and add the
DataSyncPlugin plugin directly:
Or if you are invoking the plugin with
For a more in-depth guide to setting up data synchronization features, check this page.