logoalt Hacker News

dofm • today at 8:35 AM • 1 reply • view on HN

> I fundamentally object to the idea that the schema you need for the database is the same schema that you need for the front end.

Object all you like, but it is not inherent to the idea of schema-first GraphQL, is it?

The “schema” in “schema-first” is not the database schema. It is the schema definition language document.

“Schema-first” does, broadly but not universally, suggest a mapping between the schema definition and some scheme of business model objects or structures that can be instantiated.

But it does not at all insist they are database ORM objects. It implies only that the resolving code follows from (and can be generated from) the schema definition document, rather than the schema definition presented by the GraphQL endpoint emerging from invocations in code.

They can be lightweight business logic models that do or don’t have an ORM mapping, plus invoking ordinary methods identified by attribute decorators in the schema definition.

See for example Golang’s gqlgen: https://gqlgen.com/

(Golang being a language that largely rejects the need for an ORM)

> This is ORM thinking, and ORMs are universally stupid.

Mind you, this is a rigid kind of thinking I reject. I know it’s the cool dissident voice here but I have no time for it.

> And, of course, the majority of what I've seen GraphQL as actually used, there's one query, fired at page load, that returns a giant json blob with all the data in it, because the front-end devs don't want to deal with quering for what they actually need.

Well, not if there is competence, but either way that can happen without it too, won’t it?


Replies

couchand • today at 11:05 AM

> Well, not if there is competence

It’s not just that users are holding it wrong. It’s sold as that tool. Boosters’ main argument is how simple it is to gather all the data from many different backends without needing to understand the details.

➕ show 1 reply