File tree 3 files changed +11
-11
lines changed
api-routes-apollo-server-and-client/apollo
with-apollo-and-redux/lib
3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { ApolloProvider } from '@apollo/react-hooks'
4
4
import { ApolloClient } from 'apollo-client'
5
5
import { InMemoryCache } from 'apollo-cache-inmemory'
6
6
7
- let apolloClient = null
7
+ let globalApolloClient = null
8
8
9
9
/**
10
10
* Creates and provides the apolloContext
@@ -110,11 +110,11 @@ function initApolloClient(initialState) {
110
110
}
111
111
112
112
// Reuse client on the client-side
113
- if ( ! apolloClient ) {
114
- apolloClient = createApolloClient ( initialState )
113
+ if ( ! globalApolloClient ) {
114
+ globalApolloClient = createApolloClient ( initialState )
115
115
}
116
116
117
- return apolloClient
117
+ return globalApolloClient
118
118
}
119
119
120
120
/**
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { InMemoryCache } from 'apollo-cache-inmemory'
6
6
import { HttpLink } from 'apollo-link-http'
7
7
import fetch from 'isomorphic-unfetch'
8
8
9
- let apolloClient = null
9
+ let globalApolloClient = null
10
10
11
11
/**
12
12
* Creates and provides the apolloContext
@@ -112,11 +112,11 @@ function initApolloClient(initialState) {
112
112
}
113
113
114
114
// Reuse client on the client-side
115
- if ( ! apolloClient ) {
116
- apolloClient = createApolloClient ( initialState )
115
+ if ( ! globalApolloClient ) {
116
+ globalApolloClient = createApolloClient ( initialState )
117
117
}
118
118
119
- return apolloClient
119
+ return globalApolloClient
120
120
}
121
121
122
122
/**
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
44
44
45
45
// Initialize ApolloClient, add it to the ctx object so
46
46
// we can use it in `PageComponent.getInitialProp`.
47
- globalApolloClient = ctx . apolloClient = initApolloClient ( )
47
+ const apolloClient = ( ctx . apolloClient = initApolloClient ( ) )
48
48
49
49
// Run wrapped getInitialProps methods
50
50
let pageProps = { }
@@ -69,7 +69,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
69
69
< AppTree
70
70
pageProps = { {
71
71
...pageProps ,
72
- globalApolloClient ,
72
+ apolloClient ,
73
73
} }
74
74
/>
75
75
)
@@ -87,7 +87,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
87
87
}
88
88
89
89
// Extract query data from the Apollo store
90
- const apolloState = globalApolloClient . cache . extract ( )
90
+ const apolloState = apolloClient . cache . extract ( )
91
91
92
92
return {
93
93
...pageProps ,
You can’t perform that action at this time.
0 commit comments