Sharing Logic Across TRPC Procedures
I've got multiple procedures that need to share logic. For example, I've got a query and a mutation that both return a
Technically, I've been able to write the code within both the query and mutation, but I'm struggling to find a way to share that logic.
The main issue is really a Typescript one where I can't figure out how to
The challenge I'm stuck on is figuring out the types in my util. I was able to get the prisma types, but not the
I've tried this approach https://trpc.io/docs/client/vanilla/infer-types with something like
But that produces an error
Any suggestions? thanks!
lastUpdatedBy field. Instead of returning the user id, I return their name.Technically, I've been able to write the code within both the query and mutation, but I'm struggling to find a way to share that logic.
The main issue is really a Typescript one where I can't figure out how to
The challenge I'm stuck on is figuring out the types in my util. I was able to get the prisma types, but not the
something types.I've tried this approach https://trpc.io/docs/client/vanilla/infer-types with something like
But that produces an error
'something' is referenced directly or indirectly in its own type annotation.
Any suggestions? thanks!
It is often useful to access the types of your API within your clients. For this purpose, you are able to infer the types contained in your AppRouter.