summaryrefslogtreecommitdiffstats
path: root/frontend/lib/withData.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-06-14 16:44:21 -0400
committerWes Bos <wesbos@gmail.com>2018-06-14 16:44:21 -0400
commitb1600adec47a04f60e1da07d94a3ed3906ff5aee (patch)
tree828f786da6806d7237ee5cbc5df61e552353b85b /frontend/lib/withData.js
parenta95e08cd2dd5d7ec0a0412adae02515a5f9cec4f (diff)
starter files
Diffstat (limited to 'frontend/lib/withData.js')
-rw-r--r--frontend/lib/withData.js34
1 files changed, 0 insertions, 34 deletions
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);