> 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.
(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?
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.
It is not "sold" as that tool at all? And boosters' opinions are irrelevant, aren't they? Why are you responding to what they think? As a discipline I think it's better to describe what you yourself think is wrong with a technology, rather than conjuring up someone else's loud misunderstanding of it to critique it.
(e.g. if you want to learn local AI, the very worst way you can do it is by watching most local AI boosters on youtube!)
GraphQL is just a tool that allows you to select only what you need from a graph of data in single calls rather than chains of calls where a top-level API result has to be dereferenced into another API call.
Nowhere in its marketing (such as that exists) is anything like "one query, fired at page load, that returns a giant json blob with all the data in it".
If developers are fetching massive blobs of data at page load it's a data design problem, not a GraphQL problem, and it will be true everywhere.
Granted, if you are in that domain, you might as well have a JSON API with a couple of flags to describe what you want to expand (like e.g. the Stripe API does). Nobody is saying GraphQL is always better.
Indeed, if your data itself is specifically and inevitably a tree structure, particularly one with self-nesting entities that must always be queried from close to the root with a handful of expansions, GraphQL isn't the best choice; it doesn't give you any extra tools and its syntax might be getting in the way (it doesn't have XPath-type functionality).
But if you use it properly, you can query objects in different directions, and you get all sorts of useful stuff for free, not least type safety.
Holding it right is an unavoidable part of tech stack choice, no? No technology will prevent incompetent developers misusing it.
As a practitioner, I’ve learned that neither the marketing/documentation nor the “right way to hold it” matters nearly as much, in the long run, as just what people really do.
Chalk it up to “incompetence” if you must, but GP and I (and others on this thread) have a shared experience of seeing most use of GraphQL falling into this same trap.
I've seen a lot of really bad driving. Fuck cars, amirite? Wrong abstraction.
You can criticise any tech stack with POSIWID. But it strikes me as somewhat silly to argue against a technology on the basis of deliberately conflating it with other people's misunderstanding of it.
GraphQL is a choice you can make. It has value in some applications. Strengths and weaknesses. Nobody is making you use it, not "boosters" or anyone else.
(What does "as a practitioner" mean here as a qualifier? It's so basic. Are we not stipulating to this?)
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 (1)
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.
Replies (1)
(e.g. if you want to learn local AI, the very worst way you can do it is by watching most local AI boosters on youtube!)
GraphQL is just a tool that allows you to select only what you need from a graph of data in single calls rather than chains of calls where a top-level API result has to be dereferenced into another API call.
Nowhere in its marketing (such as that exists) is anything like "one query, fired at page load, that returns a giant json blob with all the data in it".
If developers are fetching massive blobs of data at page load it's a data design problem, not a GraphQL problem, and it will be true everywhere.
Granted, if you are in that domain, you might as well have a JSON API with a couple of flags to describe what you want to expand (like e.g. the Stripe API does). Nobody is saying GraphQL is always better.
Indeed, if your data itself is specifically and inevitably a tree structure, particularly one with self-nesting entities that must always be queried from close to the root with a handful of expansions, GraphQL isn't the best choice; it doesn't give you any extra tools and its syntax might be getting in the way (it doesn't have XPath-type functionality).
But if you use it properly, you can query objects in different directions, and you get all sorts of useful stuff for free, not least type safety.
Holding it right is an unavoidable part of tech stack choice, no? No technology will prevent incompetent developers misusing it.
Replies (1)
Chalk it up to “incompetence” if you must, but GP and I (and others on this thread) have a shared experience of seeing most use of GraphQL falling into this same trap.
Replies (1)
You can criticise any tech stack with POSIWID. But it strikes me as somewhat silly to argue against a technology on the basis of deliberately conflating it with other people's misunderstanding of it.
GraphQL is a choice you can make. It has value in some applications. Strengths and weaknesses. Nobody is making you use it, not "boosters" or anyone else.
(What does "as a practitioner" mean here as a qualifier? It's so basic. Are we not stipulating to this?)
Replies (1)
Seems a fair and logical conclusion.
Tools can be easy to misuse. That makes them inferior to tools that are harder to misuse.