Is it possible to call one procedure in another?

I have multiple routers in my trpc server. For example userRouter (e.g. procedure: getUser) and postRouter (e.g. procedure: updatePost). Is it possible to call the getUser procedure from my userRouter in my updatePost procedure? Or are all procedure effectively independent.
Alex / KATT 🐱
Alex / KATT 🐱518d ago
it is, but it's better to make shared functions
Alex / KATT 🐱
Alex / KATT 🐱518d ago
if you need to though you can see https://trpc.io/docs/server-side-calls
Server Side Calls | tRPC
You may need to call your procedure(s) directly from the server, createCaller() function returns you an instance of RouterCaller able to execute queries and mutations.
TaylorFay
TaylorFay518d ago
Oh thanks, so we can use createCaller within other procedures?
Alex / KATT 🐱
Alex / KATT 🐱517d ago
theoretically yes but be careful of circular deps
ballingt
ballingt517d ago
oof I got hit with circular deps today in a something tRPC-like, interesting which cases you can get away with it in and which you can't
More Posts
Handling Query Errors at Root of App (v9)I want to show an error toast on my `NextJS` frontend every time there is an error from `useQuery` itRPC Client webpack errorAs soon as I add the client part to my legacy app i get an error and Can't figure out what is wrong.cookies, headers and authenticationin express I can do something like `res.cookie("name", "value")` for example. alternatively I can dremove queryis there any api on the trpc client to instantly remove the query out of the query cache? Basicallytrpc hook pattern. This works, but I’m not convinced…I want to call my route when a button is clicked and have access to isLoading, onError etc… I have iCatch TRPCError, ZoddError on the front-endi am throwing a TRPCError in a mutation. i dont understand how to catch this error in the OnError meimplicitly has type 'any' because it does not have a type annotation and is referenced directlyRunning into this error. I feel like it's some sort of infinite recursion issue, but not sure where Why do some examples create PrismaClient in context, and others don’tIs there a specific reason to do this or not to do this? I can imagine with the new Prisma extensionAppRouter type any?I am trying to use trpc in a Turbo repo and when I export the AppRouter on the server side it is thez.map() as an inputHi, I have ```ts z.map(z.string(), z.string()) ``` as an input, but when I try to pass the map as correct way to call TRPC inside a functioni want a user to be able to sign after they have a clicked a button but i get a hooks error. can anyCannot find namespace 'trpc'I'm getting this error when trying to access <trpc.Provider ...>. Any idea what might be going on?use tRPC for RPC calls instead of gRPCHi, I know that tRPC and gRPC are different things - despite the similar name. Nevertheless I woutRPC caching vs Vercel dynamic edge cachingWhat is the difference, or improvements, on Vercel's dynamic edge caching? tRPC server caching works