Calling tRPC procedure from within another tRPC procedure?

Is this possible?
7 Replies
barry
barry3y ago
you know what would be even better make a reusable function instead
natef
natefOP3y ago
Yeah I guess that would be possible. However, is nice to have all of the trpc context managed by default, rather than setting up a helper function that I need to pass session, prisma, etc. to while making sure everything is typesafe.
barry
barry3y ago
i dont see how it wouldnt be typesafe if you just setup the input types and output types right
natef
natefOP3y ago
Yeee I understand that -- but everything is implicitly typesafe when going through trpc routers whereas I have to explicitly write out types when creating helper functions. This is just me being nitpicky, but I was wondering if there's an easy way to call procedures from within other procedures. If not I can make helper functions
cje
cje3y ago
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.
amanuel
amanuel3y ago
^
natef
natefOP3y ago
cool thank you!
Want results from more Discord servers?
Add your server