Vulcan/packages/vulcan-lib/lib/client/apollo-client/links/state.js
2018-09-26 10:17:03 +02:00

26 lines
751 B
JavaScript

/**
* Setup apollo-link-state
* Apollo-link-state helps to manage a local store for caching and client-side
* data storing
* It replaces previous implementation using redux
* Link state doc:
* @see https://www.apollographql.com/docs/link/links/state.html
* General presentation on Links
* @see https://www.apollographql.com/docs/link/
* Example
* @see https://hackernoon.com/storing-local-state-in-react-with-apollo-link-state-738f6ca45569
*/
import { withClientState } from 'apollo-state-link'
import cache from '../cache'
const createStateLink = ({ resolvers, defaults }) => {
const stateLink = withClientState({
cache,
defaults,
resolvers,
})
return stateLink
}
export default createStateLink({})