diff --git a/packages/sync/src/DataSyncClient.ts b/packages/sync/src/DataSyncClient.ts index b3247d0b..f04e00ad 100644 --- a/packages/sync/src/DataSyncClient.ts +++ b/packages/sync/src/DataSyncClient.ts @@ -2,6 +2,7 @@ import { DataSyncConfig } from "./config"; import { createDefaultLink } from "./links/LinksBuilder"; import { OfflineClient } from "offix-client"; +import { SyncConfig } from "./config/SyncConfig"; /** * Factory for creating Apollo Offline Client @@ -15,9 +16,9 @@ import { OfflineClient } from "offix-client"; */ export const createClient = async (userConfig: DataSyncConfig): Promise => { - const offlineClient = new OfflineClient(userConfig); - const terminatingLink = await createDefaultLink(offlineClient.config); - offlineClient.config.terminatingLink = terminatingLink; + const config = new SyncConfig(userConfig); + config.terminatingLink = await createDefaultLink(config); + const offlineClient = new OfflineClient(config); await offlineClient.init(); return offlineClient; }; diff --git a/packages/sync/src/config/SyncConfig.ts b/packages/sync/src/config/SyncConfig.ts index 4618f682..78793188 100644 --- a/packages/sync/src/config/SyncConfig.ts +++ b/packages/sync/src/config/SyncConfig.ts @@ -15,6 +15,7 @@ import { } from "offix-client"; import { MutationOptions } from "apollo-client"; import { createDefaultCacheStorage } from "../cache"; +import { ApolloLink } from "apollo-link"; declare var window: any; @@ -39,6 +40,7 @@ export class SyncConfig implements DataSyncConfig { public cacheStorage: PersistentStore; public offlineStorage?: PersistentStore; + public terminatingLink?: ApolloLink; public retryOptions = { delay: {