Skip to content

Instantly share code, notes, and snippets.

@JeffMatsonPagely
Last active September 4, 2019 14:27
Show Gist options
  • Save JeffMatsonPagely/27bf5974bc2a87a87ff5baa921eb586e to your computer and use it in GitHub Desktop.
Save JeffMatsonPagely/27bf5974bc2a87a87ff5baa921eb586e to your computer and use it in GitHub Desktop.
import fetch from ‘isomorphic-fetch’;
import React from ‘react’;
import { ApolloProvider } from 'react-apollo';
import ApolloClient from 'apollo-boost';
// Wraps the entire Gatsby app with Apollo.
export const wrapRootElement = ({ element }) => {
// Register a new Apollo client.
const client = new ApolloClient({
fetch,
// Change this to your GraphQL endpoint.
uri: 'http://example.com/graphql',
});
// Wrap the element.
return <ApolloProvider client={client}>{element}</ApolloProvider>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment