Live data from Hacker News

TRPC: End-to-end typesafe APIs made easy

trpc.io

1–10 of 59 posts

Re: TRPC: End-to-end typesafe APIs made easy

#6
Only supports using Javascript/node servers it seems, so sadly it's not really usable for me.

The type exchange seems to rely on shared code between the frontend and the backend to exchange types, rather than using schemas like other systems.

Not implementing server-side events seems like a shame because they're a very capable mechanism for subscriptions without resorting to websockets.

Re: TRPC: End-to-end typesafe APIs made easy

#7
post #6

Only supports using Javascript/node servers it seems, so sadly it's not really usable for me. The type exchange seems to rely on shared code between the frontend and the backend to exchange types, rather than using schemas like other systems. Not implementing server-side events seems like a shame because they're a very capable mechanism for subscriptions without resorting to websockets.

If you're using OpenAPI, you could use this to generate TypeScript interfaces:

https://github.com/bcherny/json-schema-to-typescript

It works really well

Re: TRPC: End-to-end typesafe APIs made easy

#8
post #6

Only supports using Javascript/node servers it seems, so sadly it's not really usable for me. The type exchange seems to rely on shared code between the frontend and the backend to exchange types, rather than using schemas like other systems. Not implementing server-side events seems like a shame because they're a very capable mechanism for subscriptions without resorting to websockets.

TRPC is designed for systems where the front and back ends are both TypeScript. In that case it's simpler to have them share code than to go through an intermediary type system such as GraphQL.

Re: TRPC: End-to-end typesafe APIs made easy

#9
You can do this with GraphQL too:

https://genql.vercel.app/

https://github.com/graphql-editor/graphql-zeus

I did a 5 min talk about these newer breeds of codegen tools (where it's a single client SDK that does automatic return type inference based on the input args), they're really neat:

https://www.youtube.com/watch?v=7n3MeMFHiMk

(Skip to 2:14 to see the autocomplete/type-safety)

Post reply on HN