Replies: 1 comment
-
It's not possible. That's not really an RTKQ limitation, it's a TypeScript limitation: we need to map over those types to create new functions, and at that point is is just not possible to have any connection between |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to have a query that would return different types of data based on args
I tried
But obviously result type will be
OneData | TwoData
regardless the args passed. I need to somehow connect ResultType with QueryArgs but I don't see a way to do that.Use case: I have 5 pages that render tabular data. Queries for each one look like that:
I wanted to make a hook that would accept a page and a tab and return corresponding data. So instead of 5 separate queries I'd have one
The problem with this approach is that the type is a union of data types for each page.
Is it possible to implement dynamic
ResultType
based onQueryArgs
? Or is it a bad practice to merge all hooks into one and it's better to create a separate query for each endpoint?Beta Was this translation helpful? Give feedback.
All reactions