by newhouseb · 5y ago · 0 comments
After having iterated through a bunch of permutations of Rust frameworks, Typescript frameworks and ORMs here is a stack that I'm particularly excited about (that mirrors this article a fair bit):
- Design a Postgres database in whatever means you prefer (I prefer SQL, since it's easy to design constraints in using the full power of the DB engine).
- Use Postgraphile to auto-derive a CRUD GraphQL Schema for your database (this is similar to Hasura, but encourages using Postgres row-level security if you need fine grained access control).
- (Also) Use pgTyped for extensions to Postgraphile's schema when you want to implement mutations outside of DB functions.
- Use Apollo GraphQL Codegen in your front-end to auto-generate types for your GraphQL Queries.
The net effect of this is you get full type safety and your DB Schema is your singular source of truth (Note that I'm not auto-generating forms from JSON-Schema like this post, but this isn't necessary for our particular use case).
I don’t think we’re that far away from coming full circle back to OOP, even if the “framework” ends up having a different name.
From my perspective, I see the rise of Node and Python for web dev as a rejection of OOP, largely on the basis that web apps don’t need such a complicated set of structural abstractions. However if you look at how that domain has been innovating, my argument is that they’ve simply recreated all of the old OOP abstractions with different names. If you look at the types of abstractions used, and their associated complexity, in a typical GraphQL + TypeScript application, how are they substantially different from full OOP C# app for example? Especially if you’re using an RDBMS, or ORM, or some sort of schema for a NoSQL DB. For devs that don’t like TypeScript, JSON Schema might be appealing. But if you look at the JSON Schema spec on GitHub, one issue you see repeatedly raised is “please add full inheritance”, followed by a debate around “but that’s just OOP”. The community’s raised that issue so many times that I think they’re actually considering it now.
Typeorm looks nice, but I need polymorphism for some of our "business" logic and have pretty specific requirements about how I want correctness enforced that typeorm doesn't appear to support (but raw SQL does).