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.
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.
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.
> 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 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 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.
> 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.
The "double declaration problem" aspect is IMO overcooked n any schema-first context. If your server side library/tooling isn't doing the job of automatically generating the majority of resolvers from the schema definition language, and handling the minority with annotations, that's a problem with the library.
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.)
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.
(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?
I opened the page and immediately got turned off by all the AI vibe animations to the point where I couldn't read the content and had to close the page.
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.
“Managing hundreds of endpoints creates a maintenance nightmare”. Yes, so let's replace them with an endpoint that needs to work for an endless number of possible permutations and combinations.
Surely that's easier to debug, maintain, test, audit, and guard. What could actually go wrong?
Any of them relay? I find the way almost everybody does graph QL outside of Facebook just kind of sucks. It is very clearly meant to be done in a relay fashion with component scoped fragments, but all I've ever seen is gross giant page level queries that break often.
I haven't ever succumbed to graphql but this is what I see as the value -- with this approach you can have your components declare the data they need and automatically get that composed and delivered magically (from the front end perspective). It never felt worth it on any project I've worked on but if you aren't doing this part then it seems like a lot of pain for almost no benefit.
The main benefit in my experience is normalized caching and optimistic state. You execute a mutation, you receive back the updated entity, the normalized cache rerenders all the components that are selecting the updated fields on that entity and your whole app’s UI just stays in sync. I haven’t used Relay but URQL is nice.
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.
The more I learn about the "advantages" of these non rest frameworks, the more I think people really don't understand REST.
"All that json just for a username".
REST allows you to specify which fields you want so you can drop what's not needed over the wire.
> 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.
It does through query parameters. There are different implementations where you pass ?fields= , or there's also OData implementations.
I don't think it's too much code to implement it.
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.
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.
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.
> 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 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 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.
> 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.
How is that not covered by rest api docs though?
The nature of GraphQL is that you can't write code without an up to date schema.
You could enforce this in a REST JSON API, of course.
Same with some rest backends, FastAPI for example.
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.
The "double declaration problem" aspect is IMO overcooked n any schema-first context. If your server side library/tooling isn't doing the job of automatically generating the majority of resolvers from the schema definition language, and handling the minority with annotations, that's a problem with the library.
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.)
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?
Solving own problems, that most other stacks don't have
I opened the page and immediately got turned off by all the AI vibe animations to the point where I couldn't read the content and had to close the page.
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.
“Managing hundreds of endpoints creates a maintenance nightmare”. Yes, so let's replace them with an endpoint that needs to work for an endless number of possible permutations and combinations.
Surely that's easier to debug, maintain, test, audit, and guard. What could actually go wrong?
Honestly, I don't understand this sarcasm.
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).
I have worked in tens of React projects and there is not one that GraphQL made better. It is agonizing to see it still "surviving".
Any of them relay? I find the way almost everybody does graph QL outside of Facebook just kind of sucks. It is very clearly meant to be done in a relay fashion with component scoped fragments, but all I've ever seen is gross giant page level queries that break often.
I haven't ever succumbed to graphql but this is what I see as the value -- with this approach you can have your components declare the data they need and automatically get that composed and delivered magically (from the front end perspective). It never felt worth it on any project I've worked on but if you aren't doing this part then it seems like a lot of pain for almost no benefit.
The main benefit in my experience is normalized caching and optimistic state. You execute a mutation, you receive back the updated entity, the normalized cache rerenders all the components that are selecting the updated fields on that entity and your whole app’s UI just stays in sync. I haven’t used Relay but URQL is nice.
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.
The more I learn about the "advantages" of these non rest frameworks, the more I think people really don't understand REST. "All that json just for a username".
REST allows you to specify which fields you want so you can drop what's not needed over the wire.
> 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.
It does through query parameters. There are different implementations where you pass ?fields= , or there's also OData implementations. I don't think it's too much code to implement it.
This can be a good approach, but I’ve also seen REST APIs become a shittier ad-hoc version of GraphQL.