Global watch loading not working.
It never passes through the function that I have defined, is it necessary to put a specific parameter? any ideas?
Configuration:
apollo: {
errorHandler: '~/plugins/apollo-error-handler.js',
watchLoading: '~/plugins/apollo-watch-loading-handler.js',
clientConfigs: {
default: '~/apollo/client-configs/default.js',
},
defaultOptions: {
// See 'apollo' definition
// For example: default query options
$query: {
loadingKey: 'loading',
fetchPolicy: 'no-cache',
},
},
},
watchLoading: '~/plugins/apollo-watch-loading-handler.js',
export default (isLoading, countModifier, nuxtContext) => {
console.log(nuxtContext)
console.log('Global loading', isLoading, countModifier)
}
I have the same problem.
It seems to pass through the function only if you use apollo server-side e.g. with a smart query.
My '~/plugins/apollo.loading.js'
export default (isLoading, countModifier, nuxtContext) => {
// eslint-disable-next-line
console.log(process.server, process.client, isLoading, 'LOADING PLUGIN')
}
this prints:
true false true LOADING PLUGIN
true false true LOADING PLUGIN (repeated 0 times)
true false false LOADING PLUGIN
true false false LOADING PLUGIN (repeated 0 times)
true false true LOADING PLUGIN
true false false LOADING PLUGIN
and these are the cals I make server-side in my app. Client-side calls don't go throught the plugin.
so how to watch loading in client side?
maybe with a middleware that runs in all pages? it should work
If anyone is interested, I managed to get the Apollo global loading observer working after a bit of guidance from this thread. I posted my solution here.