-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I define InMemoryCache
options?
#542
Labels
Comments
For advanced cases, I normally use
import {
DefaultApolloClient,
provideApolloClient,
} from '@vue/apollo-composable';
import {
ApolloClient,
createHttpLink,
InMemoryCache,
} from '@apollo/client/core';
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('vue:setup', () => {
const {
$config: { baseUrl },
} = useNuxtApp();
const httpLink = createHttpLink({
uri: `${baseUrl}/graphql`,
});
const cache = new InMemoryCache({
typePolicies: {
Users: {
fields: {
details: {
merge(_, incoming) {
return incoming;
},
},
},
},
},
});
const apolloClient = new ApolloClient({
link: httpLink,
cache,
});
provideApolloClient(apolloClient);
nuxtApp.provide('apollo', { DefaultApolloClient, apolloClient });
});
}); And always remember to have a proper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your use case
I want to define caching behavior by specifying custom
merge
function inInMemoryCache
because I am getting the following errors in console.But I couldn't find a way to do this in Nuxt Apollo.
The solution you'd like
Allow customizing
InMemoryCache
Possible alternatives
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: