can you use a useQuery as a queryFn?
I am debating between making a new api or just using the cashe of another and filtering the results. Is it possible to use a useQuery within a useQuery?
5 Replies
flat-fuchsia•2y ago
You can use
queryClient.getQueryData
in your queryFn
And filter the resultunited-yellowOP•2y ago
cool thanks
stormy-gold•2y ago
Or use the
select
property and share the cache
ensureQueryData
might be even betterflat-fuchsia•2y ago
Yeah, probably. I was answering assuming the query wasn't in the same component.
Sitting in meetings and bounced around some ideas. Perhaps not even use a second
useQuery
at all and just setQueryData
in the main queryFn
and then have const data = queryClient.getQueryData([key, filtered])
wherever it's needed.
There's lots of ways to solve this tbh
Probably lame, but:
united-yellowOP•2y ago
neet assumed you needed to use the hook