Need help

import {initTRPC} from '@trpc/server';
import * as trpcNext from '@trpc/server/adapters/next';
import {z} from 'zod';
const t=initTRPC.create();
const appRouter=t.router({greetings:t.procedure.input(z.object({name:z.string()}))})
.query(({input})=>{return {text:`hello ${input?.name ??'world'}`}});
export type AppRouter=typeof appRouter;
export default trpcNext.createNextApiHandler({router:appRouter,createContext:()=>({})})
import {initTRPC} from '@trpc/server';
import * as trpcNext from '@trpc/server/adapters/next';
import {z} from 'zod';
const t=initTRPC.create();
const appRouter=t.router({greetings:t.procedure.input(z.object({name:z.string()}))})
.query(({input})=>{return {text:`hello ${input?.name ??'world'}`}});
export type AppRouter=typeof appRouter;
export default trpcNext.createNextApiHandler({router:appRouter,createContext:()=>({})})
why does t.query is not a function?
I
i_lost_to_loba_kreygasm328d ago
the error I am getting
M
michaelschufi328d ago
You are calling .query on the t.router(...) instead of the procedure:
M
michaelschufi328d ago
M
michaelschufi328d ago
you need to call it in the t.procedure chain. I.e. after .input(...)
More Posts
useQuery hook modify data on fetch.Hello is it possible to modify the data that is fetched with useQuery hook in tRPC basically im storAccepting a DecoratedProcedure with inputs and outputs that extend some given typesIs there any way to accept a DecoratedProcedure that extends { mutate: Resolver<TProcedure> } where useEffect and useMutation error about conditional rendering of hooksI am using t3 stack with tRPC, and I am trying to mark all emails as seen when the page loads by usiGuide to create an adapterIs there a guide on the docs that explains the basics to create an adapter?Does tRPC websocket client supports wss protocol?After changing the websocket client url from ws to wss, it fails to connect. Tested out the connectiGet the type of context after middlewareHow can I get the type of the context of `adminProcedure` from `export const adminProcedure = public[How To] Properly use trpc UseQuery based on currently selected itemI have a component with a video element and a flatlist. I want to utilize a trpc query to get the viData from useQuery is inferred as data: {} | undefinedMy server query returns data from database via ElectroDB. TypeScript can statically infer all properCannot access 't' before initializationHi, I'm migrating my app to a mono repo but I just can't get past this error for some reason `CannottRPC Middleware consuming memory limit on VercelHi all, I'm running into a weird error where my tRPC middleware to enforce that a user is authed, isUsing react-query parameters in tRPC for useQueryHello, the useQuery from react-query can take parameters such cacheTime, staleTime, refetchOnWindowFtRPC type error on turborepo```Types of property 'query' are incompatible. Type 'inferHandlerFn<{}>' is not assignable to ty