Skip to content

Commit 231621d

Browse files
committed
Update apollo.js
1 parent 0e9a4b4 commit 231621d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

plugins/apollo.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,29 @@ export default defineNuxtPlugin((nuxtApp) => {
5757
);
5858

5959
// Cache implementation
60-
const cache = new InMemoryCache();
60+
const cache = new InMemoryCache({
61+
typePolicies: {
62+
Query: {
63+
fields: {
64+
cart: {
65+
merge(existing, incoming) {
66+
return incoming;
67+
},
68+
},
69+
},
70+
},
71+
},
72+
});
6173

6274
// Create the apollo client
6375
const apolloClient = new ApolloClient({
6476
link: middleware.concat(afterware.concat(httpLink)),
6577
cache,
78+
defaultOptions: {
79+
watchQuery: {
80+
fetchPolicy: 'cache-and-network',
81+
},
82+
},
6683
});
6784

6885
provideApolloClient(apolloClient);

0 commit comments

Comments
 (0)