Calling tRPC procedure from within another tRPC procedure?

Is this possible?
7 Replies
barry
barry2y ago
you know what would be even better make a reusable function instead
natef
natefOP2y 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
barry2y ago
i dont see how it wouldnt be typesafe if you just setup the input types and output types right
natef
natefOP2y 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
cje2y 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
amanuel2y ago
^
natef
natefOP2y ago
cool thank you!
Want results from more Discord servers?
Add your server