diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index d436b61..ba1c817 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -7,33 +7,40 @@ createApolloClient({ // URL to the HTTP API httpEndpoint, // Url to the Websocket API - wsEndpoint = null, + wsEndpoint: null, // Token used in localstorage - tokenName = 'apollo-token', + tokenName: 'apollo-token', // Enable this if you use Query persisting with Apollo Engine - persisting = false, + persisting: false, + // Or, advanced persisting options, see https://github.com/apollographql/apollo-link-persisted-queries#options + // persisting: { + // enabled: false, + // generateHash: query => sha256() + // .update(print(query)) + // .digest('hex'), + //}, // Is currently Server-Side Rendering or not - ssr = false, + ssr: false, // Only use Websocket for all requests (including queries and mutations) - websocketsOnly = false, + websocketsOnly: false, // Custom starting link. // If you want to replace the default HttpLink, set `defaultHttpLink` to false - link = null, + link: null, // If true, add the default HttpLink. // Disable it if you want to replace it with a terminating link using `link` option. - defaultHttpLink = true, + defaultHttpLink: true, // Options for the default HttpLink - httpLinkOptions = {}, + httpLinkOptions: {}, // Custom Apollo cache implementation (default is apollo-cache-inmemory) - cache = null, + cache: null, // Options for the default cache - inMemoryCacheOptions = {}, + inMemoryCacheOptions: {}, // Additional Apollo client options - apollo = {}, + apollo: {}, // apollo-link-state options - clientState = null, + clientState: null, // Function returning Authorization header token - getAuth = defaultGetAuth, + getAuth: defaultGetAuth, }) ``` diff --git a/graphql-client/src/index.js b/graphql-client/src/index.js index f69d524..47df52c 100644 --- a/graphql-client/src/index.js +++ b/graphql-client/src/index.js @@ -100,8 +100,12 @@ export function createApolloClient ({ } if (!disableHttp) { - if (persisting) { - link = createPersistedQueryLink().concat(link) + let persistingOpts = {} + if (typeof persisting === 'object' && persisting != null) { + persistingOpts = persisting + } + if (persistingOpts.enabled) { + link = createPersistedQueryLink(persistingOpts).concat(link) } }