feat: conditional useQuery args
Describe the feature you'd like to request
Make the args in useQuery conditional that way input doesn't have to be passed if it's not required.
Currently, if a procedure doesn't include an input and you want to access the options arg in useQuery you still have to pass an input value of undefined.
const result = trpc.router.greeting.useQuery(undefined, {
onSuccess: (data) => console.log(data)
});
Describe the solution you'd like to see
If there's no input, make options accessible without the need to pass an input.
const result = trpc.router.greeting.useQuery({
onSuccess: (data) => console.log(data),
});
Describe alternate solutions
N/A
Additional information
No response
๐จโ๐งโ๐ฆ Contributing
- [X] ๐โโ๏ธ Yes, I'd be down to file a PR implementing this feature!
If it can be done in a non-hacky way, be my guest, but I'm doubtful we'll find a nice solution
It feels like this might become possible with Tanstack Query v5 - they are deprecating overloaded functions and moving to object syntax as the default. This should enable something like trpc.someProcedure.useQuery({ input?, opts })
This should enable something like
trpc.someProcedure.useQuery({ input?, opts })
We actually had that API for a while during v10 alpha/beta but got feedback that it got unclear what is trpc options and what is RQ options
If it can be done in a non-hacky way, be my guest, but I'm doubtful we'll find a nice solution
You're right. I'll close this.