HussamH
tRPC3y ago
5 replies
Hussam

How to infer types of a query

Coinsider the example
const hello = trpc.hello.useQuery();
I would like to export the type we get on hover(on hello).


I could only find how to infer the data type from the docs
const { data } = trpc.hello.useQuery()
https://trpc.io/docs/infer-types using inferRouterOutputs

The reason I am passing everything and not just data as props down to components, is because I want to access the loading, error states etc.
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.
Inferring Types | tRPC
Was this page helpful?