How do contextual queries work #44
Unanswered
gavinthomas-valtech
asked this question in
Q&A
Replies: 1 comment 2 replies
-
@gavinthomas-valtech the idea is that sometimes you application might have queries that have a "parent context". ExampleYou have an API call: const usersKeys = createQueryKeys('users', {
detail: (userId: string) => ({
queryKey: [userId],
queryFn: () => Promise.resolve({ id: userId }),
contextQueries: {
favorite:(favoriteId: string) => { ... },
},
}),
}); That way, you can use in useQuery(usersKeys.detail(userId)._ctx.favorite(favoriteId)) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Confused slightly about contextual queries. How do they work, whats the use case? to me they look the same as using a nested object. how does it compare to standard react query?
Beta Was this translation helpful? Give feedback.
All reactions