Skip to content

Instantly share code, notes, and snippets.

@peggyrayzis
Last active December 21, 2017 20:09
Show Gist options
  • Save peggyrayzis/3ae2aeb5d183c67e0f2bb18d2ba4faa2 to your computer and use it in GitHub Desktop.
Save peggyrayzis/3ae2aeb5d183c67e0f2bb18d2ba4faa2 to your computer and use it in GitHub Desktop.
Initializing Apollo Client with Apollo Link State
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloLink } from 'apollo-link';
import { withClientState } from 'apollo-link-state';
import { HttpLink } from 'apollo-link-http';
import { defaults, resolvers } from './resolvers/todos';
const cache = new InMemoryCache();
const stateLink = withClientState({ resolvers, cache, defaults });
const client = new ApolloClient({
cache,
link: ApolloLink.from([stateLink, new HttpLink()]),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment