diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-03-29 14:25:33 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-03-29 14:25:33 -0400 |
| commit | 59bdd179c34d0c5675347bd3833a2a1edf135a6e (patch) | |
| tree | 99de05f6b8ae2135e450ac90d977000a474b7590 /frontend/lib/initApollo.js | |
| parent | 75abf43dccc0145fca14217e948ea07a81afe8ec (diff) | |
move to a single instance of apollo on the server
Diffstat (limited to 'frontend/lib/initApollo.js')
| -rw-r--r-- | frontend/lib/initApollo.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/frontend/lib/initApollo.js b/frontend/lib/initApollo.js index f8a363b..4204bdc 100644 --- a/frontend/lib/initApollo.js +++ b/frontend/lib/initApollo.js @@ -1,4 +1,5 @@ import ApolloClient from 'apollo-boost'; +import { InMemoryCache } from 'apollo-boost'; import fetch from 'isomorphic-fetch'; import { endpoint } from '../config'; @@ -12,6 +13,8 @@ let apolloClient = null; function create(initialState) { return new ApolloClient({ uri: endpoint, + cache: new InMemoryCache().restore(initialState || {}), + ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once) request: operation => { if (typeof localStorage !== 'undefined' && localStorage.getItem('token')) { operation.setContext({ |
