Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
😌 (vercel#9923)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Alvarez D committed Jan 3, 2020
1 parent 2f1b15c commit fbcc0e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions examples/api-routes-apollo-server-and-client/apollo/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'

let apolloClient = null
let globalApolloClient = null

/**
* Creates and provides the apolloContext
Expand Down Expand Up @@ -110,11 +110,11 @@ function initApolloClient(initialState) {
}

// Reuse client on the client-side
if (!apolloClient) {
apolloClient = createApolloClient(initialState)
if (!globalApolloClient) {
globalApolloClient = createApolloClient(initialState)
}

return apolloClient
return globalApolloClient
}

/**
Expand Down
8 changes: 4 additions & 4 deletions examples/with-apollo-and-redux/lib/apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { InMemoryCache } from 'apollo-cache-inmemory'
import { HttpLink } from 'apollo-link-http'
import fetch from 'isomorphic-unfetch'

let apolloClient = null
let globalApolloClient = null

/**
* Creates and provides the apolloContext
Expand Down Expand Up @@ -112,11 +112,11 @@ function initApolloClient(initialState) {
}

// Reuse client on the client-side
if (!apolloClient) {
apolloClient = createApolloClient(initialState)
if (!globalApolloClient) {
globalApolloClient = createApolloClient(initialState)
}

return apolloClient
return globalApolloClient
}

/**
Expand Down
6 changes: 3 additions & 3 deletions examples/with-apollo/lib/apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {

// Initialize ApolloClient, add it to the ctx object so
// we can use it in `PageComponent.getInitialProp`.
globalApolloClient = ctx.apolloClient = initApolloClient()
const apolloClient = (ctx.apolloClient = initApolloClient())

// Run wrapped getInitialProps methods
let pageProps = {}
Expand All @@ -69,7 +69,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
<AppTree
pageProps={{
...pageProps,
globalApolloClient,
apolloClient,
}}
/>
)
Expand All @@ -87,7 +87,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
}

// Extract query data from the Apollo store
const apolloState = globalApolloClient.cache.extract()
const apolloState = apolloClient.cache.extract()

return {
...pageProps,
Expand Down

0 comments on commit fbcc0e8

Please sign in to comment.