Enable the Apollo client to be customised
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} ... />