Created
January 3, 2021 22:54
-
-
Save nutterbrand/d86edfb0975e34f7c36769f6c54b2747 to your computer and use it in GitHub Desktop.
pages/_app.js with ApolloProvider
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 App from 'next/app'; | |
import Head from 'next/head'; | |
import { AppProvider } from '@shopify/polaris'; | |
import { Provider } from '@shopify/app-bridge-react'; | |
import '@shopify/polaris/dist/styles.css'; | |
import translations from '@shopify/polaris/locales/en.json'; | |
import Cookies from 'js-cookie'; | |
import ClientRouter from '../components/ClientRouter'; | |
import ApolloClient from 'apollo-boost'; | |
import { ApolloProvider } from 'react-apollo'; | |
const client = new ApolloClient({ | |
fetchOptions: { | |
credentials: 'include' | |
}, | |
}); | |
class MyApp extends App { | |
render() { | |
const { Component, pageProps } = this.props; | |
const config = { apiKey: API_KEY, shopOrigin: Cookies.get("shopOrigin"), forceRedirect: true }; | |
return ( | |
<React.Fragment> | |
<Head> | |
<title>Sample App</title> | |
<meta charSet="utf-8" /> | |
</Head> | |
<Provider config={config}> | |
<ClientRouter /> | |
<AppProvider> | |
<ApolloProvider client={client}> | |
<Component {...pageProps} /> | |
</ApolloProvider> | |
</AppProvider> | |
</Provider> | |
</React.Fragment> | |
); | |
} | |
} | |
export default MyApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment