I used to think GraphQL was a pretty good idea. You can change the shape of your model, do complex queries, and ultimately switch out the backends. What's not to love?
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.
> You lose a lot of that if you just have a GraphQL endpoint.
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.
With hundreds of different teams all off doing their own thing, how do you read the api docs of a service you don’t know exists? Realistically you’d need some kind of central graph schema to describe all of the available services to facilitate discovery…
GraphQL was built for the needs of Facebook, not a one man band. A product of Conway’s law.
As a counterpoint: while you and other people in this thread are talking about it mostly as a sort of enterprise-tool that helps impose discipline across teams, for me as a lone developer, I have found that schema-first GraphQL has helped me retain clarity.
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.
Presumably your "REST-style" services that lie beneath GraphQL also have a schema, so it is not clear what GraphQL really adds if you don't actually have an organization graph to reflect. Navigating a graph of services is computationally inefficient so you'd only ever consider it if your people problems are greater than your compute problems, which was the case for Facebook with thousands upon thousands of developers all trying to work on the same project, but should never be the case for a small organization.
GraphQL is not a replacement for REST. Tbh I don’t even think its original purpose is that compelling. One thing it does shine at is representing shallow (<10 levels) of hierarchical or graph-like data with very little effort. I’ll put it in front of a couple of rest APIs stitched together from different systems to provide a cohesive graph representation of relationships that are otherwise a pain to stitch together. Your resolvers (business logic) don’t need to need to be aware of the graph nature of the representation
You can easily design your schema like that though and still give clients the option to throw away data at the server instead of after it goes over the wire. You don't need to add unlimited nesting at all to give so much to clients in terms of documentation etc
GraphQL was quite useful in certain situations. One example would be allowing frequent frontend changes without as many backend changes. I think you'd have to be insane to pick it as a default, though.
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.
yeah graphQL works largely if you're an API provider e.g Meta, Shopify.
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.
> It's flexible, but it adds too much undo complexity to a system that adopts it.
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.
Except worse, right? As much as I understand the critique of GQL, many "REST" APIs are just as open ended and chaotic, except they don't even standardise on how to parameterise them
GraphQL is a spec describing a schema, just like SOAP or whatever came before. It describes an API and is easy to read unlike SOAP and co. But you don't have to implement a complex Apollo server or what not to use 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.
I actually found GraphQL quite enjoyable to use. My only gripe with it is that it's hard to cache in CDNs given that it's always a POST and you have to read the body to determine whether to cache it or not.
> 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.
GQL was fantastic for two things, autogenerating an API from a very strictly defined set of exhaustively typed model objects (which is also used to produce the client api libraries), and weeding out larpers who didn't understand the n+1 footgun
The objectively main advantage of GraphQL for most orgs is forcing the API to be statically typed in a single uniform language (graphql schema). Forget everything else, I can't believe all these backend people who sneer at dynamic languages (JS/Python/Ruby) and then provide non-typed APIs, often just serializing objects that they themselves are not typing in their own code.
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.
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.
Replies (9)
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.
Replies (1)
Replies (3)
You could enforce this in a REST JSON API, of course.
Replies (1)
GraphQL was built for the needs of Facebook, not a one man band. A product of Conway’s law.
Replies (1)
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.
Replies (1)
Continue this thread (1 replies) →
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.
Replies (1)
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.
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.
Replies (1)
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.
> 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.
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.
Replies (1)
This comment illustrates quite clearly how naive GraphQL boosters are about prior art.