Skip to content

Instantly share code, notes, and snippets.

@bartcis
Created July 17, 2019 13:42
Show Gist options
  • Select an option

  • Save bartcis/cf37cf3da534a352a07210b11976c1bb to your computer and use it in GitHub Desktop.

Select an option

Save bartcis/cf37cf3da534a352a07210b11976c1bb to your computer and use it in GitHub Desktop.
Simple integration of React and Apollo
import React from 'react';
import ReactDOM from 'react-dom';
import './styles/index.css';
import App from './components/App';
import * as serviceWorker from './serviceWorker';
import { ApolloProvider } from 'react-apollo';
import { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
const httpLink = createHttpLink({
uri: 'http://localhost:4000'
});
const client = new ApolloClient({
link: httpLink,
cache: new InMemoryCache()
});
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
)
serviceWorker.unregister();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment