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
barry2y 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
ippo2y ago
sure, so the mistake in my thinking is that I think about tRPC as an public API, right?
barry
barry2y ago
tRPC is a tool You setup endpoints between apps and share types without codegen
ippo
ippo2y 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
barry2y 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
ippo2y 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
barry2y ago
yes
ippo
ippo2y ago
lets say you can decide to recode airbnb again, would you pick tRPC?
barry
barry2y ago
sure
ippo
ippo2y ago
EVEN if you have to support different platforms (android and IOS)?
barry
barry2y ago
theres create-t3-turbo atm which is expo and a next app by default with trpc so sure
cje
cje2y ago
if i was building airbnb id probably pick graphql
ippo
ippo2y ago
what do you mean by that ?:)
cje
cje2y 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
barry2y ago
in my defense he said if i had to build airbnb
ippo
ippo2y ago
@cje that would be my next question how do you work with tRPC in a team? (a team with a mono repo in general)
cje
cje2y ago
if its a small team with a monorepo, you... just work with it? idk what you want to know if i had to build airbnb alone, id give up
ippo
ippo2y ago
@barry can you rephrase your create-t3-turbo answer again, and what you wanted to emphasize with it?
cje
cje2y ago
you can consume trpc from multiple frontends for example a next.js frontend and a react native frontend
barry
barry2y ago
You seemed to imply it wasn't possible, so I just said how I would do it
ippo
ippo2y ago
@cje if you are in a team, you have many moving parts and I do not see how tRPC can hold everything together and setting the contracts that nobody can break
cje
cje2y ago
if someone breaks the contract, the build step fails so as long as you have ci set up, you cant merge anything that breaks the contract
ippo
ippo2y ago
@barry what can create-t3-turbo do what create-t3-app can not?
cje
cje2y ago
theyre both just templates
barry
barry2y ago
It's just a "template" for a monorepo version of a t3-app
ippo
ippo2y ago
isn't tRPC all about mono repo by default/design?
barry
barry2y ago
create-t3-app isn't
cje
cje2y ago
run both and take a look at them
ippo
ippo2y ago
ohh, so create-t3-app is just the server, without any frontend
barry
barry2y ago
no create-t3-app is a scaffolding cli which generates some various templates based on your choices
barry
barry2y ago
Create T3 App
Create T3 App
The best way to start a full-stack, typesafe Next.js app.
Want results from more Discord servers?
Add your server