Last active
December 21, 2017 20:09
-
-
Save peggyrayzis/3ae2aeb5d183c67e0f2bb18d2ba4faa2 to your computer and use it in GitHub Desktop.
Initializing Apollo Client with Apollo Link State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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