T
TanStack3y ago
continuing-cyan

How to use multiple queryClient options

I'm using React query for normal network requests, but I am also using it to handle sqlite queries in React Native. I would like the normal network requests to use basically the default ootb settings, but for the sqlite queries, I want to change most of the default behaviors since they are not network requests. What would be the best way to use multiple types of query settings? Would it make sense to create 2 different QueryClientProviders with different queryClient settings and instances?
2 Replies
other-emerald
other-emerald3y ago
you can use queryClient.setQueryDefaults to set defaults for a fuzzily matching key. so if your sqllite queries all start with ['sqlite'] in the key, you can do:
queryClient.setQueryDefaults(['sqlite'], { staleTime, refetchInterval })
queryClient.setQueryDefaults(['sqlite'], { staleTime, refetchInterval })
continuing-cyan
continuing-cyanOP3y ago
Awesome thanks!

Did you find this page helpful?