From 59bdd179c34d0c5675347bd3833a2a1edf135a6e Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 29 Mar 2018 14:25:33 -0400 Subject: move to a single instance of apollo on the server --- frontend/lib/initApollo.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'frontend/lib/initApollo.js') 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({ -- cgit v1.3