Grats: A More Pleasant Way to Build TypeScript GraphQL Servers
jordaneldredge.com
jordaneldredge.com
I recognize a lot of the problems described here in the docs (the "How Grats Works" [1] page is a good read). I could see this library fulfilling a similar role to Strawberry, for a backend written in TypeScript rather than Python.
Overall, it looks like a compelling implementation of some good ideas from the author, who incidentally is on the Relay team at Facebook, so he's probably done a lot of thinking in this problem space. Next time I'm working on a project with a TypeScript backend, I'll definitely take a look at this.
[0] https://www.splitgraph.com/blog/graphql-schema-stitching
https://x.com/captbaritone/status/1748020699263045659?s=46
Example project with this setup working can be found here: https://github.com/captbaritone/grats-relay-example
We actually started with Postgraphile, but found it was too much magic and eventually moved to defining resolvers explicitly with Strawberry for each service (which was much easier to do once we added the stitching layer).
Are there? I honestly don't know. I feel like it depends on how you count them. Are there JS/TS/nodejs "Backends For Frontends" (BFFs)? Yeah, I could see that, but then in that case there's at least as many other backends behind them, probably written in something else. Are there JS/TS/nodejs backends, mediating interaction with upstream databases in large enterprise organizations? I highly doubt it.
https://trends.google.com/trends/explore?date=all&geo=US&q=S...
Slonik is much newer, and is Postgres only. But there is a general trend seen in many different projects that support safe SQL execution using tagged template literals in JavaScript, which is a fantastic technology. Slonik was one of the first projects that went this route, but there are now many others.
In general I think it's a mistake to look for a single "market leader" for node DB access. There are many high quality libraries that are favored by different teams for various reasons.
https://trends.google.com/trends/explore?date=all&geo=US&q=S...
I despise NodeJS and its entire ecosystem. The number of incidents I’ve been dragged into which are directly linked to its use is too damn high.
Not sure why you highly doubt it, when you admit 'I honestly don't know' and the truth is 20 seconds of googling away.
backend web frameworks - https://github.com/vanodevium/node-framework-stars
ORMs - https://github.com/emanuelcasco/typescript-orm-benchmark
Not to mention pretty much every major cloud service (AWS, GCP, etc) has first-class JavaScript/TypeScript SDKs.
As for cloud service SDKs, are you saying that many node backends rely on cloud SDKs?
[0] https://www.bellcorpstudio.com/blog/how-netflix-is-using-nod... [1] https://medium.com/walmartglobaltech/migrating-large-enterpr...
> As for cloud service SDKs, are you saying that many node backends rely on cloud SDKs?
Almost anything that uses a cloud service like DynamoDB is going to 'rely on cloud SDKs'... the language is irrelevant.
Netflix is not enterprise. Walmart is.
As for DynamoDB, is that database more common, or less common, than relational databases like Oracle and MSSQL?
Maybe google 'enterprise company' after you finish googling which database is more common.
SQLite is #1 by far, with MySQL a distant second.
In enterprise it was a lot of raw SQL as well, in large part because there was a lot of different DBs to support from db2 to SQL Server to Postgres
- node-postgres
- node-mysql2
Query Builder / Other thin clients: - knex - kysely - slonik ORM: - TypeORM - MikroORM - Objection.js - DrizzleORM - Prisma (actually runs a separate binary)
Not quite Fortune 500 tier, but certainly not small potatoes.
Before I worked at an "all Typescript" shop, lots of times someone on the front end would need some small additional piece of data or an extra API call from the server team. They almost never did it themselves, and it wasn't so much that they couldn't read/code in Java, it's that the environment setups were so different. It just was rarely worth it to them to spend all the time setting up the backend environment (again, in a language they could understand but weren't "used to" in their day-to-day) to make a couple line change. Worse, some enterprising folks would set it up, but then since they only needed to make backend changes once in a blue moon, the next time they needed to make a change they'd have to spend a ton of time again getting their environment updated.
There is huge value to using the same language, and coding environments, across front and back ends.
E.g. in the past I've seen it take weeks (that is, one or two sprints' worth) to add a teeny bit of data to the front end. Reason being the request had to go to the back end team, then it had to get prioritized and added to the sprint, yada yada everyone's been there. When everything is in the same language I've seen front end devs be much less reticent to just make the change themselves.
As an aside, I've also kind of turned against "full stack" as largely unrealistic. There are of course exceptions, but most people seem to feel much higher affinity for one side or the other, and as a result often are just so much more effective and efficient when the scope is more limited to their comfort zones.
Most seem to think that JSON is god’s gift to mankind, and that RDBMS are weird boxes you throw said JSON – along with random scalars for fun – into, and then you can blame the DB for being old and slow when your latency is abysmal.
Then you have worked with an abnormally large amount of shitty devs.
Or, do you want to offer solutions using your preferred tools?
There are no wrong answers, as far as I'm concerned. I'm just curious which you would prefer.
If it’s open source, and only for self gratification then I’d use my preferred tools so I can convert more people into using my preferred tools and thus get a broader better community.
The things you're mentioning see irrelevant if you're using typescript. You may be alluding to the question of why even use node, but that would be beyond the scope of discussion.
"What exactly are we trying to do here?"
Are we trying to offer GraphQL servers? Or are we trying to offer GraphQL servers in Node? Because, if it's the latter, then I'll move on my merry way. If it's the former, then a new way of building GraphQL servers in Node may not be all that relevant if there's a majority of developers who already aren't building servers of any type in Node.
Unlike Pothos, this implementation-first approach is able to leverage simple type script names and types, whereas Pothos requires you to explicitly define all the names and types using their builder-pattern-for-graphql-SDL API.
More here on why Grats does not use decorators like type-graphql: https://grats.capt.dev/docs/faq/why-use-comments/
You can read more about how I ended up settling on docblocks here: https://grats.capt.dev/docs/faq/why-use-comments