From 3af1c5a486eca9f135ec0b73dfc1f97daffdaaf4 Mon Sep 17 00:00:00 2001 From: Dara Hayes Date: Tue, 8 Oct 2019 11:20:33 +0100 Subject: [PATCH] fix: ensure config is initialized properly --- packages/sync/src/DataSyncClient.ts | 7 ++++--- packages/sync/src/config/SyncConfig.ts | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) 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: {