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. This is ORM thinking, and ORMs are universally stupid.
The classic example is user passwords. For the database schema, it makes perfect sense to store the password hash alongside the user's other details. For the front end, it's positively dangerous to return the password hash when all the front end needs is the user name and avatar url.
I think part of the attraction of GraphQL was being able to specify that front-end schema properly, and let the front end create its own queries on that schema.
But then folks decided that the front-end schema should be generated from the back-end schema because maintaining two schemas was too hard.
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.
> 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?