flexible tRPC - is it as flexible as GraphQL?

airbnb and graphql had the problem to have scalable APIs that can grow, are flexible and are backward compatible graphQL solves this problem, so lets say we have something like this:
persons {
id
firstName
lastName
email
pets {
id
name
}
}
persons {
id
firstName
lastName
email
pets {
id
name
}
}
now I can grow add other relations to my persons, without breaking my code, so persons can have addresses, bank accounts, children, cars, bought products how does tRPC grow that way how does tRPC is telling you how to have flexible interface?
31 Replies
barry
barry17mo ago
tRPC is not that flexible, the point is you define your endpoints and then it's rock solid and you have upmost type safety without code gen and validation of inputs through the use of Zod.
ippo
ippo17mo ago
sure, so the mistake in my thinking is that I think about tRPC as an public API, right?
barry
barry17mo ago
tRPC is a tool You setup endpoints between apps and share types without codegen
ippo
ippo17mo ago
but in tRPC you have to think what you need and what you want to render, everything else is implementation details that you not make public for others like a public graphql or rest api, correct?
barry
barry17mo ago
I'm not sure what you mean by that exactly, but yeah, it's mostly intended for intern communication, you can use it for public api's too with trpc-openapi
ippo
ippo17mo ago
let me rephrase: in REST you have an endpoint and you know that many people are using it, so you have to think twice how to define it if you want changes with a breaking nature, you can use tricks like versioning, so you have something like www.abc.com/api/version2/users But in tRPC you do not think in terms like being stable or care about breaking changes you can break it and tRPC will tell you if your frontend can not deal with it long story short: tRPC is not about flexibility, tRPC is about a better communication about front end backend for a mono non public api app agreeing with that ?:)
barry
barry17mo ago
yes
ippo
ippo17mo ago
lets say you can decide to recode airbnb again, would you pick tRPC?
barry
barry17mo ago
sure
ippo
ippo17mo ago
EVEN if you have to support different platforms (android and IOS)?
barry
barry17mo ago
theres create-t3-turbo atm which is expo and a next app by default with trpc so sure
cje
cje17mo ago
if i was building airbnb id probably pick graphql
ippo
ippo17mo ago
what do you mean by that ?:)
cje
cje17mo ago
because it would take a large team to build it trpc is great when a small team wants to move fast graphql slows you down in mvp stage due to schema, resolvers, n+1, etc
barry
barry17mo ago
in my defense he said if i had to build airbnb
Want results from more Discord servers?
Add your server