But over time I've come to realize that those features aren't all that helpful. More fixed and static responses are much easier to manage. They force the caller to do things in a performance oriented way for the backend. And, importantly, all telemetry is based on CRUD/REST style endpoints. You lose a lot of that if you just have a GraphQL endpoint. It makes it supremely hard to see how you are being called or what you can drop.
It's flexible, but it adds too much undo complexity to a system that adopts it.
Well thought out REST endpoints organically grown as usage is required or observed trumps hyper flexible endpoints created because "Who knows what the user might need". And particularly in the age of LLMs and AI where adding and deploying new endpoints can take hours rather than days. Or making/updating a client for a service is extremely fast, there's just no reason not to go down that route.
I don't see telemetry as being a problem for internal use. Just log operation names instead of endpoints (and enforce unique operation names, which you can do with Apollo's operation manifests). It's also pretty easy to move off of it when all your callers are internal: just turn the operations into REST endpoints.
I do agree that AI fixes the "our backend team can't add project count to the companies endpoint for two weeks" problem, and that GraphQL was often chosen for no reason.
the whole argument of frontend changes is weak but when you got massive number of api clients (customers) then yeah since they can use a version of your api on their own cadence.
[dead]
> Well thought out REST endpoints organically grown as usage is required or observed trumps hyper flexible endpoints created because "Who knows what the user might need"
The issue with having all those endpoints is that you start waiting for one endpoint response before calling another, and that adds a lot of latency for end users.
Of course, this is valid reasoning up until the point where you end up with a REST API with a comparable amount of complexity. If you end up with REST endpoints that accepts params for which fields and nested relationships to include in the response, then you've got most of the complexity of GraphQL.
REST isn't a spec, it's a "philosophy" with no normative implementation. There are specs based on REST though, so use that if you want to. But I'm personally not going back to pointless debates about PUT usage or idempotent bullsit... which is why I use GraphQL.
Of course, GraphQL was, quite explicitly, intended to be a layer over the CRUD/REST-style endpoints. It is interesting how it tried to become something else once it left the hands of Facebook, but I guess that's par for the course when few have Facebook-type problems but like to latch onto trendy things.
> And particularly in the age of LLMs and AI where adding and deploying new endpoints can take hours rather than days.
GraphQL's main value proposition, when humans were still writing code, was providing a map of all the services in the organization to even know what was out there available to use. In a large organization it is easy to not realize that a service exists at all. LLMs can equally benefit from something like that.
I worked in an org that introduced a GraphQL gateway that was mandated to be the only point of contact to the backend. That was literally the only way to get backend developers to provide god damn types consistently.
Sure the same can be achieved with OpenAPI, but the GraphQL gateway _forces_ it, you can't work around it, you can't be "we are too busy now, we will do it later" or "it is just a POC (that ends up in prod)". It doesn't help that OpenAPI is terrible to use in some runtimes (like Go) and most people who actually do use OpenAPI don't validate _every_ request/response against the spec before processing it.
GraphQL in this regard got it right, you either conform to the spec you created or you GTFO.
Another big thing is consistency in implementing "long-running queries" (GraphQL subscriptions) since there is no standard for this kind of stuff in the non-GraphQL-world it ends up with an org having dozens of different ways of doing subscriptions each with its own bespoke authentication/authorization madness.
If you're not schema-first, I can see the issue. But then why aren't you? Code-first is a lot of extra weight to carry unless you're getting into icky meta-programming territory.
(I guess on reflection what it comes down to is that I don't really see the point of GraphQL if you're not going schema-first. If you are, and you have a modestly complex API, I do.)
[deleted]
[dead]
[dead]
Where's the fragments, directives, global object identification, subscriptions, updating local data from mutations, being able to apply filters to child entities? Standard spec that's language agnostic? what "power"? This doesn't seem to even come with the server adapters that make GraphQL so powerful (JS example drizzle [1], or pg_grahpql). This reads like a garden variety RPC library built off a poor understanding of GraphQL.
I didn't want to come out to bat for GraphQL because the server side is a viper nest of accidental complexity as you get in the weeds. But if you follow Relay style GraphQ L[2] there's a ton of power there and I wish Meta actually documented their library rather than letting Apollo and react-query style libraries dominate leading to everyone using it 'wrong'.
If I did capital N need this level of granularity, Why would I pick a non-standard JS library when there's a standard with an ecosystem and much more powerful?
[1] https://orm.drizzle.team/docs/graphql [2] https://alan.norbauer.com/articles/relay-style-graphql/
The era of "AI geocities"...
---
I did try to go back and read the content (a few times), but couldn't relate with the problems. Clients will ALWAYS have dependencies on the server, no framework can erase that.
I didn't experience the GraphQL train, so can't relate to all the problems I guess.
> The Power of GraphQL, without ``GraphQL``.
> The last framework that actually makes sense, in the age of AI.
This headline tells us nothing except it's something to do with GraphQL.Then
> Why Cobalt?
> It's simple and powerful.
> Cobalt never gets in your way.
> It extends GraphQL but doesn't force you to use it manually.
> You get the iteration speed of tRPC and the flexibility of GraphQL.
Great, but you haven't told us what it actually is yet.> ENDPOINT FATIGUE & OVER-FETCHING
> Managing hundreds of endpoints creates a maintenance nightmare. You fetch huge JSON blobs just to display a username.
Talk about hyperbole.
Who says I'm managing hundreds of endpoints?
Who's fetching 'huge' JSON blobs just to display a username?
Surely that's easier to debug, maintain, test, audit, and guard. What could actually go wrong?
Just a little bit of tooling and it works well, we have like 300 models and it never felt a shore (something like https://github.com/teamstarter/graphql-sequelize-generator, there are a lot of similar initiatives).
Aaaand I’m out.
REST allows you to specify which fields you want so you can drop what's not needed over the wire.
How? GET doesn't formally allow you to specify what to fetch, QUERY isn't a thing yet, and building an end point for each unique use case doesn't scale well and results in a complicated API.
You could enforce this in a REST JSON API, of course.
[deleted]
GraphQL was built for the needs of Facebook, not a one man band. A product of Conway’s law.
Because you can use the schema judiciously to avoid all sorts of problems and to help you visualise the API boundary much more clearly, and rethink it where you need it.
I also find schema-first stuff quite useful in a prototype context. If I ultimately realise that there are fewer API flows that will matter, and I want to optimise for speed, I can embody those in a JSON API. It's also useful to lay down a framework to anticipate change in a networked app with internal APIs.
But really any tool that centralises specifications in a way that drives code-generation is potentially a useful thing for a lone developer, because it helps you retain perspective.
I use it less than I did, but I don't think I would benefit in the same way from this code-first approach from this library.
This comment illustrates quite clearly how naive GraphQL boosters are about prior art.
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.
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?
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.
(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.
But yes, declaring component data needs via fragments is great and then you build the query document by combining the fragments so you only fetch what your UI needs. You can really make your app perform well on high-latency mobile networks by reducing the amount of round trips. You don’t need GraphQL to do that per se but it helps.
There aren't any "REST services" below the GraphQL layer. I am not using GraphQL as a service orchestration layer on top of REST services. Representing an organisation graph is not the only value of GraphQL.
> so you'd only ever consider it if...
> but should never be the case for...
This is weirdly black-and-white and rather unimaginative thinking.
I thought about spelling out a more detailed explanation of the situations where I think people miss out on the value of schema-first GraphQL, particularly in content flows or interpreted languages, as a lone developer building complex prototypes/proof of concept/v1 apps, but honestly the tone and tenor of comments here strongly suggests that it isn't worth the typing time. Like with any nuanced discussion of ORMs; HN has orthodox hatreds.
It may be increasingly in the past for me, at any rate, because of LLMs.
I don't know if gqlgen-style approaches make as much sense for LLMs because code generation is a significant indirection, and even an intensively schema-first approach like Laravel Lighthouse means asking the LLM to write in an additional language and manage the mapping. Good for me, not for the LLM.
Plus I am moving on from all interpreted languages at the back end; it no longer makes any kind of sense to deploy PHP, Python or Node apps when you are responsible for the whole deal. The supply chain attack surface is too severe, the internet-facing attack surface is worse, etc.; it's just a recipe for lying awake worrying about the next shell vulnerability.
We did already discuss that other uses emerged, but it was originally designed to have "REST-like" services behind it. I mean that's cool if you found some other use for it, but that isn't what it was designed for or what we were talking about.
> I think people miss out on the value of schema-first GraphQL
That's possible, but I don't think you've made the general value proposition of a dynamic graph system clear. In my experience, if my application has simple boundaries, which is most apps, then there is no meaningful graph traversal to speak of and if my application is complex and does have a need for graph-like structures then things like the n+1 problem still make leveraging it impractical. I don't think many are working on systems that are truly graph problems and optimized for such. If you take away the graph dynamism then there are much better schema tools and always has been.
> I don't know if gqlgen-style approaches make as much sense for LLMs
There is no avoiding Conway's law, so that depends on your organization structure. If LLMs have changed how your organization functions then it is possible that whatever value you saw before no longer applies, but it is likely that Facebook's problems GraphQL was created to solve remain. LLMs aren't exactly magicians.
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.
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?)
[dead]
Seems a fair and logical conclusion.
Tools can be easy to misuse. That makes them inferior to tools that are harder to misuse.