While a query is disabled it still creates entries in the query cache
I noticed that even if a query is set to
enabled: false
it still creates entries in the query cache when the query key changes. Is that the desired behavior or am I doing something wrong?6 Replies
extended-salmonOP•2y ago
I have create a Stackblitz here to showcase what I mean
https://stackblitz.com/edit/vite-vue3-ts-tailwind-mdfjg2?file=src%2Fpages%2FHome.vue
Giannis Koutsaftakis
StackBlitz
Vue query - disabled query - StackBlitz
Next generation frontend tooling. It's fast!
extended-salmonOP•2y ago
You'll see that the cache gets populated with empty entries when you increment the counter even if the query is disabled

fair-rose•2y ago
yes, it's the desired behaviour.
unwilling-turquoise•2y ago
Yes. This only disabled calling the queryFn
extended-salmonOP•2y ago
@M00LTi can you elaborate more?
ambitious-aqua•2y ago
By using
useQuery
you create the observer that watches cache store.
Even if it's disabled you want to be updated when another component has the same query enabled, or you call queryClient.setQueryData
.