How to define a react-query query key for related resources that do not include parameters

Viewed 1417

Say I have multiple related queries:

  1. api/rewards/plan
  2. api/rewards/achieved

After a mutation, I need to refetch both queries.
What would be the recommended way to construct the query keys for the queries above and what would be the query key to provide queryCache.refetchQueries?

The documented type of the query key parameter is:
queryKey: String | [String, Variables: Object] | falsy | Function => queryKey

Does this make sense?

  1. useQuery(["rewards", {plan: true}], ...)
  2. useQuery(["rewards", {achieved: true}], ...)
  3. queryCache.refetchQueries("rewards")

Thanks

0 Answers
Related