I use vue-apollo for working with GraphQL.
I installed it via vue add apollo
and as a result a have vue-apollo.js which I use for configuration.
Current configuration:
// Call this in the Vue app file
export function createProvider (options = {}) {
// Create vue apollo provider
const apolloProvider = new VueApollo({
defaultClient: apolloClient,
defaultOptions: {
$query: {
fetchPolicy: 'no-cache',
// fetchPolicy: 'cache-and-network',
},
},
errorHandler (error) {
// eslint-disable-next-line no-console
console.log('%cError', 'background: red; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;', error.message)
},
})
return apolloProvider
}
Want I want to do is to disable cache for any query. Right now it's disabled when I do queries via apollo:
component property. But when I run queries manually via $apollo instance, it doesn't work.
It does work if I put fetchPolicy for every query, for example:
const response = await this.$apollo.query({
query: documentSetListQuery,
variables: {
...mapFilters(this.getActualFilters(this.filters), whitelistFilters),
regime: false
},
fetchPolicy: 'no-cache'
})
Is it possible to setup no-cache
globally if I run the query manually via this.$apollo.query
? Just to avoid fetchPolity: 'no-cache'
repetition