TanStackT
TanStack3y ago
1 reply
full-green

How to refetch partial data?

Hi o/
I'm new to working with react-query and I'm not sure how to best handle this problem: I have a useQuery hook that calls my api which returns an object like this:
{
  "invites": [...],
  "members": [...],
  "roles": [...],
  "...": "...",
}


On initial page load, I want to fetch everything.
On a button click, I'd like to call the api with some additional parameters which restricts the response to only invites or members or roles.

I could have a query hook for each key, but this seems cumbersome. Is there a way to modify the queryFn to take in some parameter so I can pass that along to the api?
Was this page helpful?