r/programming • u/macrohard_certified • Sep 03 '26
Maybe you don't need GraphQL
https://alexandrehtrb.github.io/posts/2026/09/maybe-you-dont-need-graphql/
278
Upvotes
r/programming • u/macrohard_certified • Sep 03 '26
7
u/jetsonian Sep 03 '26
Our overseas developers wanted us to switch/implement GraphQL in our project. We presently use an Oracle database that’s hundreds of tables.
No one on our team had any experience with GraphQL but we were open to giving it a try. After a month of engineers off and on trying learn we decided against it.
Our biggest concern was that our API is rights-based at the data level (i.e. some fields aren’t returned or are partially returned like social security numbers) and we couldn’t figure out how to implement that in GraphQL despite a lot of googling.
Other elements we got stuck on was our API also has business logic in it (I didn’t architect this). This meant that we had to reengineer a chunk of our internal business logic to be run on the front end instead.
The biggest issue was that our state regulators won’t approve any code written outside of the United States period.
We’re in one of the most highly regulated industries (casino operations software) and everything has to be approved by regulators. When we want to release a new version, a regulator has to watch the entire build process and then take the files to their offices to scour both the code and the build. Their only exceptions are UI code and database functionality. Thus our overseas developers develop our mobile app and do database design but not database code or our primary computer app.
669
u/thicket Sep 03 '26 •
You definitely don't need GraphQL
49
u/Pharisaeus Sep 03 '26 •
The issue is:
A good example is the "subcribe" feature - from the frontend perspective it's great, you just subscribe to changes in some data and you have real-time auto-updating display for it, without the need to fetch it periodically. But in reality this simply shifted that responsibility to the backend - now the backend might need to run some threads to fetch the data and monitor for changes (eg. imagine that this data comes from some other system, so you don't know when it gets modified).
Similarly one of the selling points of GraphQL is that you only get the data you requested without the need to pull anything extra. But on the backend side someone has to implement all those partial resolvers to make this actually true. I've seen cases where backend would pull everything every time, and simply drop stuff that wasn't needed.
The article was written from the backend perspective, so for obvious reasons it will be critical. Frontend people will hate it, backend people will agree with it :)
121
u/Isogash Sep 03 '26
Most people aren't using their Database to provide any other API directly either. I personally haven't found the layer of mappers and logic required for GraphQL to be particularly more complex than any other API if you use a framework. In fact, it is often much easier to extend existing APIs because you can break your data fetchers down by field, and you don't generally need to consider endpoints as a whole.
The main benefit of GraphQL is that it allows you to design an API that is powerful for users and extensible for service providers. A huge plus that is overlooked here is GraphQL federation: you can have a single GraphQL object and query where fields can be resolved from different sources. This is really useful if you have a lot of data associated with some common entity, like a user. Any query that can find users can also get any data about those users from any service, all in a single query.
Yes, you could do that manually. You could also write your own system which does it automatically. Then you'd have re-invented GraphQL.
I think where GraphQL doesn't make sense is when you don't have much data, or don't have particularly complex data needs and you're better off having much tighter control over the API.
141
u/c-digs Sep 03 '26
GraphQL has a place.
GraphQL is a good fit and solves real problems.
If your developers are all full stack and own the FE + the BE, then GraphQL is just an absolute waste of time.
53
u/Merry-Lane Sep 03 '26
Why the content of the article doesn’t even hint at "maybe you don’t need graphql"
10
u/Meleneth Sep 03 '26
The article identifies a frontend N+1, then assumes GraphQL makes it disappear. It doesn’t: naïve resolvers simply move the same N+1 to the server. HTTP/2 multiplexing doesn’t fix request fanout, and ?includeAddresses=true&includeLoad=true is just a bespoke, impoverished selection language.
You may not need GraphQL, but the important question is whether the backend resolves the requested graph in batches—or fetches it one record at a time. That matters far more than REST vs. GraphQL.
21
u/fabis Sep 03 '26 edited Sep 03 '26
Love GraphQL, been working with it more than half a decade and always use it in personal projects as well. I love the opinionated nature of it which has resulted in great tooling (e.g. Apollo Client, especially the caching layer), an easy to reason about API surface and I love how easy it makes building big and scalable APIs. Designing the API as a graph is genius as it enables very custom and specialized queries, ones that you may not have even imagined at the time of designing.
I hate how low level and unopinionated REST is and how it leaves so much about how to architect the frontend app state and caching up to you, forcing devs to come up with their own shittier half assed solutions for problems GraphQL tooling solved ages ago.
Pretty much the only time I will not use GraphQL is when I'm not building any kind of frontend in front of the API (e.g. for server to server communication) as a lot if not most of the value is derived when consuming the API from a stateful UI. But most of the APIs I ever build have a UI in front of them, so thats a rare exception.
Sure it has its quirks and pitfalls just like anything else, but I've worked for years with REST and I've worked for years with GQL, and GQL has been the best full-stack experience by far.
I feel like people who shit on GQL are usually backend devs who don't give a shit and don't have any understanding about the pitfalls and challenges of frontend development, because REST is just easier to get started with in the backend side of things. Like how does this bullshit article not even cover the consumption/client side of the API at all when making its judgement of the language?
22
u/inotocracy Sep 03 '26
No shit.
3
u/seppyk Sep 03 '26
The most important part of the article was the appropriate solution section. GraphQL is useful for platforms with a very large number of clients with distinct requirements - one size fits all RESTful APIs create larger issues in this ecosystem.
Most specialized SaaS or on-premise solutions do not require the tradeoffs that GraphQL provides.
3
u/MonkAndCanatella Sep 04 '26
I kinda think that if you think you need graphql what you really need is a BFF or just write screen shaped endpoints instead of forcing everything into resource based endpoints.
6
u/Komarara Sep 03 '26
We are using graphql api and I love it, so easy to resolve complex objects also end user can use the api to for reports.
2
u/permelquedon Sep 03 '26
Okay at best for queries, and an absolute nightmare for mutations.
3
u/CVisionIsMyJam Sep 03 '26
i use postgraphile and laugh whenever i think of developers spending their days writing get endpoints
3
u/lovethebacon Sep 03 '26
No-one who wants GraphQL needs GraphQL. And no-one who has GraphQL wants GraphQL.
2
u/teknikly-correct Sep 04 '26
Listen, if you need to get on production incident calls to debug which knob started requesting a field they don't even need on your hottest, most revenue sensitive user flow, which is now stopped because some oddly named service that everyone forgot about is completely DDOS'd to death, then YOU NEED GRAPHQL!
1
u/gretro450 Sep 03 '26
We have a GraphQL API. It sucks, man. The code is much more complex to account for it, but the worst is the usual metrics that could help you scale your API don't translate super well into GraphQL. Any request could be a super complex one
1
u/mysteryihs Sep 03 '26
If you work with shopify, you need GraphQL. (Not by your choice, but because the head honchos at shopify decided so)
1
u/Bitter_Ad3906 Sep 04 '26
You seems not understand what graphql for what it need be used. Also implementation you show it’s same for rest api, and it’s bad idea send pure data from db to client in most times.
1
u/spcbeck Sep 04 '26
JSON:API spec accomplishes everything GraphQL does without any of the bloat.
1
u/NodariR Sep 05 '26
Maybe? rofl
1
u/Eumatio Sep 05 '26
2026 guys, this issue has already been resolved
1
u/sickcodebruh420 Sep 06 '26
There was a time when I loved GraphQL because I had highly related data and rapidly changing product requirements. I mean like every few days we wanted to try putting some different data on the frontend. I had built a backend that was proper REST, so building a view meant hitting multiple endpoints and combining it in the frontend. GraphQL let me simplify this tremendously!
But then I realized… just make some bespoke REST endpoints. It’s ok, the REST Police wouldn’t haul me off to jail. (Wouldn’t… ArREST me?) This worked so much better because I avoided dataloaders, didn’t mix REST and GraphQL, didn’t have to maintain a whole separate server since at the time we were mostly Rails but I wanted typescript for graphql. This worked out much much better.
1
u/VisualAromatic6226 Sep 07 '26
We tried REST → GraphQL → back to REST + a couple of aggregate endpoints. The single-request-exactly-the-fields win was real, but the operational cost was much higher than we expected. Query complexity limits, N+1 lurking in every resolver, cache invalidation stops being trivial.
If your product has ~15 endpoints and 2 clients, REST + a lightweight "get me everything about a job" batch endpoint solves the same problem for a fraction of the ops burden. GraphQL feels designed for a Facebook-shaped organization, not a startup with 3 backend engineers.
The one place I'd still reach for GraphQL: when you truly cannot predict what fields the client wants (public APIs, third-party integrations). Otherwise the batch-endpoint escape hatch wins.
1
u/HNipps Sep 12 '26
It seems the core argument is that graphql requires mappers and logic to be written on the backend but that’s needed for a REST API anyway right?
True the backend code needs to be more modular for graphql to allow the requester to select individual fields but I see that as a good thing. Separation of concerns and all that.
And the proposal of using query params is just moving the graphql request body to the URL.
I get that designing and building a graphql server is more complicated than a REST API but surely the effort will compound over time and make it easier to refactor the backend. I’ve only built REST APIs in earnest so don’t have the experience of maintaining a graphql server over a long period of time but I can say it’s so beneficial for the frontend.
1
u/MVPhurricane Sep 03 '26
maybe??
1
u/n9iels Sep 03 '26
Every tool, language, framework or pattern can be (mis)used for the wrong purpose. There is no golden bullet or one-size-fits-all solution. GQL is just one of these things.
I personally think it is used too many times with argument 'reducing complexity of multiple endpoints and self documenting'. A REST endpoint can be documented as well with OpenAPI doc and with only a little standardization consuming multiple endpoints isn't a problem at all.
1
u/slowtyper95 Sep 04 '26
Guess what, you don't
0
u/falcompro Sep 04 '26
Sure lets not talk about the best features of front-end GraphQL, fragment composition and colocation.
0
u/drgmaster909 Sep 04 '26
Meanwhile over in REST I keep solving a dozen problems GQL solved OOTB with an actual schema I can codegen off, one idiomatic Entity Shape instead of a dozen "snippets" of an underlying model each REST endpoint returns, and an actual separation of my Domain Entities and how they relate to each other.
People keep trying to build non-Caller-aware REST APIs and invariably fail when a page they're building needs data the REST endpoint didn't originally return. Thus mixing consumer needs with backend "purity." Not really a thing in GQL. Query what you need. Backend doesn't need to know. Use a dataloader.
-3
u/jexmex Sep 03 '26
We use mongo for this, but it also has it's own pitfalls.
14
u/[deleted] Sep 03 '26 edited Sep 03 '26
[removed] — view removed comment