Created
March 20, 2018 19:28
-
-
Save nanlabsweb/4f7a7c99c3729d1b1bb81bbeceebaee9 to your computer and use it in GitHub Desktop.
How to setup Apollo Client library in a React app.
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 React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { BrowserRouter } from 'react-router-dom'; | |
import { ApolloProvider } from 'react-apollo'; | |
import { ApolloClient } from 'apollo-client'; | |
import { HttpLink } from 'apollo-link-http'; | |
import { InMemoryCache } from 'apollo-cache-inmemory'; | |
const client = new ApolloClient({ | |
link: new HttpLink({ uri: 'http://localhost:5010/graphql' }), | |
cache: new InMemoryCache() | |
}); | |
ReactDOM.render( | |
<ApolloProvider client={client}> | |
<BrowserRouter> | |
<App/> | |
</BrowserRouter> | |
</ApolloProvider>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment