Version: Next

Introduction to Data Synchronization

The @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.


The @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.

npm install @graphback/datasync


Add annotations to your data models:

type User {
id: _GraphbackObjectID
name: String

The preferred and simpest way to add data sync functionality is to use the createDataSyncAPI function which wraps buildGraphbackAPI:

import { createDataSyncAPI } from '@graphback/datasync'
const { typeDefs, resolvers, contextCreator } = createDataSyncAPI(modelDefs, { db });

Alternatively, you can use the default buildGraphbackAPI and add the DataSyncPlugin plugin directly:

import { buildGraphbackAPI } from 'graphback';
import { DataSyncPlugin } from '@graphback/datasync'
const { typeDefs, resolvers, contextCreator } = buildGraphbackAPI(schema, {
plugins: [
new DataSyncPlugin({
enabled: true

Or if you are invoking the plugin with graphback generate:

schema: './src/schema.graphql'
documents: './client/src/graphql/**/*.graphql'
# path to data mode file(s)
model: './model/datamodel.graphql'
packageName: '@graphback/datasync' # required to dynamically load
enabled: true

For a more in-depth guide to setting up data synchronization features, check this page.