Skip to content

Enable the Apollo client to be customised

Aanand Prasad requested to merge custom-apollo-client into master

A new prop, makeApolloConfig, can be passed to the Root component to customise the Apollo client config before it's instantiated. For example, if I want to use apollo-link-state to persist state in the in-memory cache:

import { Root } from 'pubsweet-client'
import { withClientState } from 'apollo-link-state'

const makeApolloConfig = ({ cache, link, ...config }) => {
  const clientStateLink = withClientState({
    cache,
    resolvers: {...}
  })
  return { cache, link: clientStateLink.concat(link), ...config }
}

<Root makeApolloConfig={makeApolloConfig} ... />
Edited by Aanand Prasad

Merge request reports