Skip to content

Instantly share code, notes, and snippets.

@bartcis
Created August 11, 2019 09:16
Show Gist options
  • Save bartcis/6ad3c47f9548fbc36eceade6d23891dd to your computer and use it in GitHub Desktop.
Save bartcis/6ad3c47f9548fbc36eceade6d23891dd to your computer and use it in GitHub Desktop.
// Context for React Apollo
const httpLinkReactApollo = createHttpLink({
uri: 'http://localhost:4000'
});
const clientReactApollo = new ApolloClient({
link: httpLinkReactApollo,
cache: new InMemoryCache()
});
// Context for GraphQL Hooks
const clientGraphQLHooks = new GraphQLClient({
url: 'http://localhost:4000',
cache: memCache(),
});
ReactDOM.render(
// Remove this wrap if you use GrapQL Hooks
<ApolloProvider client={clientReactApollo}>
{/* Remove this wrap if you use React Apollo */}
<ClientContext.Provider value={clientGraphQLHooks}>
<App />
</ClientContext.Provider>
</ApolloProvider>,
document.getElementById('root')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment