Get all the queryKeys used on the React tree #7396
Unanswered
pedroapfilho
asked this question in
Ideas
Replies: 1 comment
-
Hi, sine you've asked me on input here regarding my key-hierarchy library: I don't think const queryKeys = defineKeyHierarchy((dynamic) => ({
users: {
getAll: true,
byId: dynamic<string>().extend({
get: true,
update: true,
}),
},
}))
const activeQueryKeys = client.getQueriesData({})
const usersKeyBase = queryKeys.users.__key
const childQueryKeys = activeQueryKeys.filter((queryKey) => deepEqual(queryKey.slice(0, usersKeyBase.length), usersKeyBase)) With Of course, this does not take component hierarchy into account. Just the key hierarchy. |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I don't know how doable it is, but it would be very helpful, for some complex error handling cases, to have a way to get all the keys used on a specific tree, like,
Then, on the
Parent
, we could have something like auseGetDownstreamQueryKeys
, that gets all the queryKeys from that node, and returns it as an array.This, in conjunction with
Query Observers
, could make a very neat error handling case, where we can check if any of the requests downstream failed, and we could show the status of that specific page/widget/whatever, making it easier to handle complex apps error cases.Beta Was this translation helpful? Give feedback.
All reactions