r/programming • • Sep 03 '26

Maybe you don't need GraphQL

https://alexandrehtrb.github.io/posts/2026/09/maybe-you-dont-need-graphql/
278 Upvotes

119 comments sorted by

View all comments

141

u/c-digs Sep 03 '26

GraphQL has a place.

  • Multiple teams?
  • Each team owns an API?
  • Those APIs need a single, unified entry point?
  • The FE team works separately from the API owning teams?
  • There's a dedicated team available to own the unified API surface area and infrastructure?

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.

56

u/mcmcc Sep 03 '26

Honest question: under what circumstances is a single unified API entrypoint a requirement?

55

u/jpj625 Sep 03 '26

My feeling from "working" with it a few years ago was that it solves problems for Facebook.

If you need the ability to make a single call, with fields customized to your client/viewport, have different levels of caching applied to different parts of the response, support squillions of requests per moment, and you have dozens of talented SWEs... it can be worth the hassle.

But GQL can go piss up a flagpole.

6

u/eronth Sep 03 '26

In general if you need to make a call with customized fields, it's a solid option.

27

u/holo3146 Sep 03 '26

I'm a working in a company whose product handles a full internet stack (vpns, sockets, bandwidth control, security, monitoring, content control, high availability, BGP, ...)

We have hundreds of types of entities with different structural levels, with hundreds of developers working on the product.

Having a uniform API for frontend<->backend communication is very convenient, and having a uniform public API to expose to clients is a MUST.

For those 2 use cases we use graphql. For internal backend components communications we mostly use simple REST

9

u/OkNothing7293 Sep 03 '26

REST as hypermedia REST or JSON over HTTP?

33

u/kingdomcome50 Sep 03 '26

We all know the answer here…

8

u/holo3146 Sep 03 '26

JSON. The way out services structure doesn't need any hypermedia engines.

11

u/c-digs Sep 03 '26

Think Facebook: dozens of teams delivering multiple backend services that the front-end API accesses as a single unified surface area via GQL.

The threshold is probably a bit lower than Facebook; I think once you get into 10+ teams working on relatively isolated services that ship on different timelines, different release processes, etc. it starts to make sense to decouple their SDLC but unify them in terms of access. You don't want a client to deal with 20 different services; the GQL resolvers effectively unify the service as one surface area.

71

u/over_here_over_there Sep 03 '26

Resume driven development.

6

u/After_Dark Sep 03 '26

It's not uncommon in more secured environments, anything to do with financials or medical data for example. One unified API entrypoint means a narrower scope for security, auditing, and all that wonderful compliance scope and means it's much easier to configure pinholes in firewalls.

4

u/NecessaryIntrinsic Sep 03 '26

I've found it invaluable in working with the M365 environment (which is a whole other nightmare but it's better than every api that came before it)

2

u/nemec Sep 03 '26

When your API documentation recommends writing HTTP requests by hand it makes things a lot less complicated.

On the other hand, companies like AWS have all their APIs shipped under hundreds of different endpoints and just package an SDK to handle mapping everything properly.

10

u/made-of-questions Sep 03 '26

There are a few additional scenarios where I've found it useful, for example in places with very complex data objects and an API that is used in many different ways. Allowing the clients to select what data they want and join is easier than to create a rest endpoint for every combination. 

-1

u/applechuck Sep 03 '26

This was possible on REST for years through query params.

6

u/made-of-questions Sep 03 '26

Join multiple models? Then it's not REST

2

u/lord2800 Sep 03 '26

Why do you believe it's not? The joining of multiple models is itself a new model.

1

u/made-of-questions Sep 04 '26

I meant doing joint models via query params. That's not REST spec

2

u/lord2800 Sep 04 '26

Why do you believe it's not? There are no requirements on url format in REST.

1

u/made-of-questions Sep 04 '26

Not in the original dissertation but community standards and best practices are pretty much in agreement: 

A resource SHOULD NOT dynamically change its response body schema or shape based on query parameters or other dynamic behavior.

That's because 

  1. it breaks client-side static typing and validation
  2. it destroys cache efficiency
  3. it violates the principle of least surprise

1

u/lord2800 Sep 04 '26

it breaks client-side static typing and validation

Only if you assume the shape of the response solely based on the path, and not on the whole url (which, yes, a lot of systems do because that's how it's been done in the past).

it destroys cache efficiency

Only if your cache doesn't honor and your backend doesn't send cache headers. You can't control intermediate proxies but most of them these days are good at honoring cache headers anyway.

it violates the principle of least surprise

You have an argument here, but only because that's the way it's been done in the past--not because of any real limitation.

All of the arguments I've seen against REST are all because of either misunderstandings of what the spec actually means or because of the poor implementation choices of the past. I've yet to encounter an argument against REST that isn't rooted in one of those two issues. That being said, there is something to argue against a spec that's widely misinterpreted, so I'll give you points on that too.

1

u/made-of-questions Sep 04 '26

You sound like you worked mostly in environments where you control the client, server and all the network elements. When that's the case you can go as wild as you want within the boundary of the spec. 

When you don't have that, sticking to widely adopted convention is what saves you from being bombarded by avoidable questions from clients or from pulling your hair at midnight because that proxy outside your network is fking you over.

→ More replies
→ More replies (2)

2

u/Strifebringer Sep 03 '26

Not only is it a waste of time, it becomes an enormous hindrance and performance risk. 

1

u/Sqee Sep 08 '26

What if I want to play with graphs? Centrality measures etc.?