vue-query-nuxt
vue-query-nuxt copied to clipboard
retry in defaultOptions for queryClient doesn't work
Environment
"@hebilicious/vue-query-nuxt": "^0.3.0"
Reproduction
https://codesandbox.io/p/devbox/4pq98t
Describe the bug
I'm trying to setup retry globally through nuxt.config.ts, but it doesn't work.
I made a simple example in a codesendbox, so you can see how I'm doing.
Open Chrome DevTools on the page. There you can see that it trying to retry (4 times) '/api/fail' (fake handler made through /server/api/fail.js - just throws an error).
But in the nuxt.config.ts I've set retry function with return failureCount < 1; so it shouldn't retry. Also there is console.log but we cannot see it in a console.
https://codesandbox.io/p/devbox/4pq98t
Maybe I'm doing something wrong?
Additional context
No response
Logs
No response
Hello, because the Nuxt design https://nuxt.com/docs/guide/going-further/runtime-config#serialization we cannot use non-serializable (Infinity, NaN, function... ) value in nuxt.config.ts
use the vue-query.config.ts way, e.g.
https://nuxt.com/modules/vue-query#_4-advanced-configuration
export default defineVueQueryPluginHook(({ queryClient }) => {
// here, set the default options
queryClient.setDefaultOptions({
queries: { staleTime: Infinity },
});
return {
pluginReturn: { provide: { } }, // nuxt plugin return value
vueQueryPluginOptions: { queryClient }, // You can pass dynamic options
};
});
Thank you for answer 👍