(no title)
haney
|
2 years ago
I'm currently in the process of removing tRPC from our codebase. It's been a nightmare of tight coupling. I've also found that it encourages more junior developers to not think about interfaces / data access patterns (there's a mapping from Prisma straight through to the component). It's fantastic for rapid prototyping but really paints you into a corner if you ever want to decouple the codebase.
miraantabrez|2 years ago
spankalee|2 years ago
I think if you're defining a JSON API, that TypeScript is a natural fit since its types line up with with JSON - ie, number is the same in both and if you want something special like an integer with more precision, then you have to model it the same way in your JSON as your TypeScript interfaces (ie, a string or array). This makes TS good even for backends and frontends in other languages. You can also convert TS interfaces to JSON Schema for more interoperability.
thinkingkong|2 years ago
Swizec|2 years ago
There’s a learning curve to these things. It always starts with type FunctionIWroteTodayArgs = …, which is useless and tells you nothing.
After a few iterations (this takes years) people gradually realize that the goal is to describe your domain and create types/interfaces/apis that are reusable and informative, not just a duplication of your code. You then get more useful types and things start really flying.
I guess what I’m saying is work on that with your team, not on ripping out tRPC.
killthebuddha|2 years ago
dclowd9901|2 years ago
If you’re talking about decoupled services, that’s about business domain composition more than type description. And those types benefit from a higher level description/reusability/transportability.
epolanski|2 years ago
I don't see how declaring an http client server side and consuming it client-side can be a worse thing.
We use the same pattern of creating services that then every consumer can use (a web interface, a cli, etc) and the fact that those things never get to break is a massive improvement over anything I've seen in the past.
haney|2 years ago
welder|2 years ago
haney|2 years ago
macrael|2 years ago
calebio|2 years ago
IMO, at a minimum, you have your API layer model, your internal model, and your database model with a mapping layer at each boundary.
I rarely have problems when I structure it that way, but when working on applications that pass the same model from their API down to their database, or vice-versa, it's always full of the same types of problems that comes with tight coupling.
yieldcrv|2 years ago
there is a “REST Wrapper” project out there, but learning that was even needed was … fun
I don't mind it, we found other ways to test
Out of curiosity, how do you add a memcache to tRPC if you dont want to write directly to the prisma database
JCharante|2 years ago
vendiddy|2 years ago
alexdotjs|2 years ago
Would that help your team?
Happy to give you a demo if you reach out on Twitter dms or email (alex@trpc.io)
replygirl|2 years ago
unknown|2 years ago
[deleted]
random_kris|2 years ago