Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
fix: ensure config is initialized properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dara Hayes committed Oct 8, 2019
1 parent 83c2993 commit 3af1c5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/sync/src/DataSyncClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,9 +16,9 @@ import { OfflineClient } from "offix-client";
*/
export const createClient = async (userConfig: DataSyncConfig):
Promise<OfflineClient> => {
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;
};
2 changes: 2 additions & 0 deletions packages/sync/src/config/SyncConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -39,6 +40,7 @@ export class SyncConfig implements DataSyncConfig {

public cacheStorage: PersistentStore<PersistedData>;
public offlineStorage?: PersistentStore<PersistedData>;
public terminatingLink?: ApolloLink;

public retryOptions = {
delay: {
Expand Down

0 comments on commit 3af1c5a

Please sign in to comment.