Skip to content

Instantly share code, notes, and snippets.

@larkintuckerllc
Created June 2, 2018 09:39
Show Gist options
  • Save larkintuckerllc/2e74187e1693421365d7276d10e99f96 to your computer and use it in GitHub Desktop.
Save larkintuckerllc/2e74187e1693421365d7276d10e99f96 to your computer and use it in GitHub Desktop.
Apollo Client by Example: Part 1 - 1
import { ApolloClient } from 'apollo-client';
import { withClientState } from 'apollo-link-state';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloProvider } from 'react-apollo';
import React from 'react';
import ReactDOM from 'react-dom';
import defaults from './graphql/defaults';
import resolvers from './graphql/resolvers';
import typeDefs from './graphql/typeDefs';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
const cache = new InMemoryCache();
const client = new ApolloClient({
cache,
link: withClientState({ resolvers, defaults, cache, typeDefs }),
});
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
registerServiceWorker();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment