From b1600adec47a04f60e1da07d94a3ed3906ff5aee Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 14 Jun 2018 16:44:21 -0400 Subject: starter files --- frontend/lib/withData.js | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 frontend/lib/withData.js (limited to 'frontend/lib/withData.js') diff --git a/frontend/lib/withData.js b/frontend/lib/withData.js deleted file mode 100644 index e47a9db..0000000 --- a/frontend/lib/withData.js +++ /dev/null @@ -1,34 +0,0 @@ -import withApollo from 'next-with-apollo'; -import ApolloClient from 'apollo-boost'; -import { LOCAL_STATE_QUERY } from '../components/Cart'; - -function createClient({ headers }) { - return new ApolloClient({ - uri: process.env.NODE_ENV === 'development' ? 'http://localhost:4444' : 'http://localhost:4444', - request: operation => { - operation.setContext({ - fetchOptions: { - credentials: 'include', - }, - headers, - }); - }, - clientState: { - resolvers: { - Mutation: { - toggleCart(_, variables, { cache }) { - const { cartOpen } = cache.readQuery({ query: LOCAL_STATE_QUERY }); - const data = { data: { cartOpen: !cartOpen } }; - cache.writeData(data); - return data; - }, - }, - }, - defaults: { - cartOpen: false, - }, - }, - }); -} - -export default withApollo(createClient); -- cgit v1.3