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() 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.
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.
Nick408d ago
The query type is a React Query thing, it’s a little customised but generally the types they export will probably work for you You could also ‘ReturnType<typeof trpc.hello.useQuery>’
Hussam365d ago
this does not work. I am trying to look into the other option. thanks a lot Nick Ended up using QueryObserverResult import { QueryObserverResult } from '@tanstack/react-query';
More Posts
Data Visualisation/Chartsis anyone using tRPC on data visualisation (say bar chart/line chart) in a scenario close to a bankitrpc + AWS Lambda (through cdk)Hi all, has anyone successfully integrated tRPC with AWS Lambda? My current stack is API Gateway + LIs it possible to narrow an output schema if the query optionally doesn't return all fields?I have a router procedure that has an input schema that has an optional `filter` that changes the shFetching different server url than defined in configIs it possible to access the reactQuery instance and fetch different server url? I would like to useinput using z.or not working properlyi have an input like this let input = z.object({ name: z.string().optional() }).or(z.object({ How can I disable batching with fastify adapter?I cant seem to find a way to disable batching for my server, and this link doesnt help me much httpsIssue with monorepo architecture ant tRPCHi, we had an issue with batched requests that if we batch some requests they produce a TRPCClientErUsing tRPC in CRON jobsHey everyone, this might be a very stupid question, but is it possible to use tRPC inside a CRON joasync createContext for Express AdapterBeen debugging an odd behavior for the past hour, it seems like that an async function does not workIs it possible to split the router definition with the imlementation?I want to define the server router(input\output\meta) in a separate package from the server package Cache not working for `useQuery`I have a query like this: ```js const { data: article, isFetching } = api.public.getArticle.useQueryZod File Upload Validation with Open-Api Support?Hi guys, anyone know how to validate file upload with zod and get also open-api support?