From 21baf56ca199fd9743726c5166b02da4aa6d977b Mon Sep 17 00:00:00 2001 From: Peggy Rayzis Date: Tue, 22 May 2018 12:52:21 -0400 Subject: Small edits to client creation --- frontend/lib/withData.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'frontend/lib/withData.js') diff --git a/frontend/lib/withData.js b/frontend/lib/withData.js index aa0ba88..6fc0213 100644 --- a/frontend/lib/withData.js +++ b/frontend/lib/withData.js @@ -5,9 +5,11 @@ import { LOCAL_STATE_QUERY } from '../queries/queries.graphql'; function createClient({ headers }) { return new ApolloClient({ - uri: process.env.NODE_ENV === 'development' ? 'http://localhost:4444' : 'http://localhost:4444', - ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once) - request: async operation => { + uri: + process.env.NODE_ENV === 'development' + ? 'http://localhost:4444' + : 'http://localhost:4444', + request: operation => { operation.setContext({ fetchOptions: { credentials: 'include', @@ -19,7 +21,7 @@ function createClient({ headers }) { resolvers: { Mutation: { toggleCart(_, variables, { cache }) { - const { cartOpen } = cache.read({ query: LOCAL_STATE_QUERY }); + const { cartOpen } = cache.readQuery({ query: LOCAL_STATE_QUERY }); const data = { data: { cartOpen: !cartOpen } }; cache.writeData(data); return data; -- cgit v1.3