tRPC useQuery ReturnType
Working on a custom auth provider (just wanted to do all the stuff myself, learn the flow, ya know) and trying to get the result of a trpc
useQuery
passed through context. I can't seem to figure out how to type the context, as the data
always comes out as unknown.
6 Replies
Inferring Types | tRPC
It is often useful to wrap functionality of your @trpc/client or @trpc/react-query api within other functions. For this purpose, it's necessary to be able to infer input types and output types generated by your @trpc/server router.
this just gives me the actual return type, not the useQuery result call (which I want for some of the other rqc specific stuff, like status)
oh you can't get the type of an entire useQuery
Alex explained why a while ago, cant remember exactly but basically it's not coming anytime soon
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
argh, used to be in v9 😢
yeah this doesn't work. Really needs a cast to a QueryResult while also keeping the data / error types.
WAIT
Actually it kinda did work?
this is about as close as I can get
need some way to type error
This is just dumb because I'm recreating the error by hand lol
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View