We’ve use an API style similar to tRPC at Notion, although our API predated tRPC by 4 years or so. You can build this kind of thing yourself easily using Typescript’s mapped types, by building an object type where the keys are your API names, and the values are { request, response } types. Structure your “server” bits to define each API handler as a function taking APIs[“addUser”][“request”] and returning Promise . T…
Is there some trick to doing validation of request data using this process? That's a valuable part of using something like tRPC, JSON Schema + type generation, zod, etc.
tRPC – Build and consume typesafe APIs without schemas or code generation
41–50 of 223 posts
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#42I've used tRPC and Next.js for a couple of personal projects and it's been a great experience. Hard to beat on iteration speed, especially when used with a pre-configured template like Create T3 App: https://create.t3.gg/ .
Does it now work properly with Next 13 and server components?
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#43Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#44tRPC seems cool, but seems riskier to go with an alternative to REST or GraphQL, especially if you intend to make your API public and/or have multiple consumers of your API.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#45Earlier quoted context omitted.
What does the Royal Shakespeare Company have to do with RPC? (or please define/link acronyms folks may not know!)
I'm guessing React Server Components which is apple to oranges with tRPC.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#46I'm a big fan of tRPC. It's amazing how it pushed TypeScript only stacks to the limit in terms of DX. Additionally, it made the GraphQL community aware of the limitations and tradeoffs of the Query language. At the same time, I think tRPC went through a really fast hype cycle and it doesn't look like we're seeing a massive move away from REST and GraphQL to RPC. That said, we see a lot of interest in RPC these days a…
Could you expand on that? Our graphql types are generated from our federated schema whenever it changes, and response types for queries / mutations are generated whenever you save a file.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#47RPC IDL keeps being reinvented by those that fail to understand where we came from. Pop fashion industry.
OpenAPI, JSON-RPC, and JSONSchema have existed for a pretty long time now. The industry has more or less standardized on JSON for data interchange and parsers/generators for JSON abound in every programming language, so it makes sense to do all this stuff with JSON. I've never seen IDL before but I looked up some examples and it does seem useful for RPC calls. But I'm not exactly eager to switch, it looks like it's m…
I think you kind of made his point for him.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#48Earlier quoted context omitted.
Is there some trick to doing validation of request data using this process? That's a valuable part of using something like tRPC, JSON Schema + type generation, zod, etc.
Deepkit is a fantastic solution for this. It uses a compilation step to inject metadata about types into plain JS. https://deepkit.io/
What happens if the Deepkit guy retires? What if I want to run my code without waiting for 11 minutes of typechecking? What if there’s a bug somewhere in there?
There’s way too much risk for me to consider Deepkit for production.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#49I'm a big fan of tRPC. It's amazing how it pushed TypeScript only stacks to the limit in terms of DX. Additionally, it made the GraphQL community aware of the limitations and tradeoffs of the Query language. At the same time, I think tRPC went through a really fast hype cycle and it doesn't look like we're seeing a massive move away from REST and GraphQL to RPC. That said, we see a lot of interest in RPC these days a…
> it made the GraphQL community aware of the limitations and tradeoffs of the Query language Could you expand on that? Our graphql types are generated from our federated schema whenever it changes, and response types for queries / mutations are generated whenever you save a file.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#50I've used tRPC and Next.js for a couple of personal projects and it's been a great experience. Hard to beat on iteration speed, especially when used with a pre-configured template like Create T3 App: https://create.t3.gg/ .
Does it now work properly with Next 13 and server components?