import { PlayGround } from 'react-display-window/lib/components'; import Example from './src/docs/Example'; import BuiltWith from './src/docs/BuiltWith';
More info is available on Github.
Install it as any other npm package:
$ npm i apollo-link-computed
Next, add it to your apollo client:
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from 'apollo-link-http';
import { ApolloLink } from 'apollo-link';
import { setContext } from 'apollo-link-context';
import { withClientState } from 'apollo-link-computed';
import resolvers from './resolvers';
const TokenLink = () => setContext(() => {
return {
headers: {
'Authorization': 'Token',
},
};
});
const cache = new InMemoryCache();
const link = ApolloLink.from([
TokenLink(),
withClientState({
resolvers,
cache,
}),
new HttpLink({
uri: 'http://my-api-host/graphql',
credentials: 'same-origin'
}),
]);
export default new ApolloClient({ link, cache });