spherehq/sphere

View on GitHub
packages/platform/gatsby-browser.js

Summary

Maintainability
A
1 hr
Test Coverage
import * as React from 'react'
 
import { ApolloProvider } from 'react-apollo'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { persistCache } from 'apollo-cache-persist'
 
import ApolloClient from 'apollo-boost'
import fetch from 'isomorphic-fetch'
 
import './src/styles/global.css'
import Layout from './src/components/layout'
 
const cache = new InMemoryCache()
 
const windowGlobal = typeof window !== 'undefined' && window
 
persistCache({
cache,
storage: windowGlobal.localStorage,
})
 
const client = new ApolloClient({
uri: 'https://graph.sphere.sh',
fetch,
cache,
})
 
Similar blocks of code found in 2 locations. Consider refactoring.
export const wrapPageElement = ({ element, props }) => {
return (
<ApolloProvider client={client}>
<Layout {...props}>{element}</Layout>
</ApolloProvider>
)
}