I'm trying to disable cache on Apollo, therefore I'm following the documentation apollo-client
, but I cannot success, I get all the time this warning ApolloBoost was initialized with unsupported options: defaultOptions
Does anyone have the same warning ?
import Vue from 'vue'
import ApolloClient from 'apollo-boost'
const defaultOptions = {
watchQuery: {
fetchPolicy: 'network-only',
errorPolicy: 'ignore'
},
query: {
fetchPolicy: 'network-only',
errorPolicy: 'all'
}
}
const client = new ApolloClient({
defaultOptions: defaultOptions,
)};
It looks like it's because you are using Apollo Boost, a wrapper around Apollo Client with slightly different API.
Try changing your import from:
import ApolloClient from "apollo-boost";
to:
import ApolloClient from "apollo-client";
or in v3:
import { ApolloClient } from '@apollo/client';
The "apollo-client" is more low level and harder to use. That's probably why the team created "apollo-boost".
But looking at the source code "apollo-boost" is a good way to understand how to use the low-level "apollo-client". For example:
import ApolloClient from 'apollo-client';
import { FetchResult } from 'apollo-link';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
// in v3, the types moved:
// import { ApolloClient } from '@apollo/client';
const apolloClient = new ApolloClient({
link: new HttpLink({
uri: '/graphql',
credentials: 'same-origin',
}),
cache: new InMemoryCache(),
defaultOptions: {
query: {
errorPolicy: 'all',
},
},
});
See also the docs on migration from Apollo Boost to Apollo Client like Intellidroid said.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With