You probably don't need GraphQL

https://lemmy.world/post/14278794

You probably don't need GraphQL - Lemmy.World

“GraphQL got a lot of hype because it enabled building typesafe APIs with a better developer experience than any other API”

Haha.

No.

The experience was awful.

Come at me, type-safe bros. Your favorite tech still sucks.

Actually, that’s true, across the board. Your favorite technology, it has serious flaws. Frankly, it sucks.

Now get off my lawn.

Unless it’s that medicine that prolonged your favorite grandparent’s life and quality. That technology is pretty great. But the rest still sucks.

I haven’t used GraphQL personally but I’ve heard interesting things about it. It sounds like you’ve been burned by it so I’d be interested to hear more about your opinion beyond that you think it sucks if you’re willing to share some more details.

Oh, sure.

Primaly, it was needlessly complicated.

I went down a rabbit trail of (unconvincing) “here’s why the way that has worked for decades for you isn’t good enough anymore” leading to “and that’s why we decided not to implement this quality of life feature you have learned to expect”.

It had a “only fit for the truly faithful” cult vibe, last time I checked it, which was about a year ago.

The big thing that turned me off was a lack of tooling to auto-generate an HTML page that helps explore the API. It seems to me that it would be easier to do so when using strong types, not harder.

So did you ever actually use it? Or did you just read docs about it.
Thank all that is holy, I did not use it. I had other options, which I chose, because I’m the boss.

The experience was awful.

I did not use it.

Hmm. You sure have a strong hatred of a thing you never used, about which your main objection (no HTML explorer) is completely untrue.

I don’t think anyone would say you need GraphQL for a tiny 10-20 endpoint project. It’s for big projects.

well, there’s a schema description built into compliant graphql apis and a tool called graphiql that consumes that and provides exactly that api explorer that you’re looking for. many graphql backend frameworks embed graphiql

docs.github.com/en/graphql/overview/explorer

Explorer - GitHub Docs

Get started, troubleshoot, and make the most of GitHub. Documentation for new users, developers, administrators, and all of GitHub's products.

GitHub Docs
Today I learned! Thanks!

…by someone who didn’t really deeply understand the HTTP specification, or at least couldn’t really articulate why they needed a new tool that used less…

Thousand yard stare at SOAP

Yo dawg, I heard you like XML over HTTP so I put XML in HTTP in your XML over HTTP.

So many technologies doing crap that plain old HTTP already does:

  • name a resource: URL
  • discover verbs for a resource: OPTIONS
  • execute a verb: the actual request
  • define a response type: Headers

Thousand yard stare at SOAP

Yo dawg, I heard you like XML over HTTP so I put XML in HTTP in your XML over HTTP.

Made me spit my drink, laughing. Thank you. Very true.

If Json wasn’t status quo, coming from a language that’s status quo, all these comments could be reversed against it.

And well, if you’re not using JavaScript, Json is not that great anyways.

What I like about graphql that Json over rest doesn’t have it: fragments and types.

On types: have you ever got across bad swagger documentation? Like a parameter called something unclear like user type, with no explanation of what it is or examples? Well in graph ql, that parameter use likely to be called userType, which if you go into the schema file, you’ll likely see it’s an enum and you’ll also see all possible values. If your backend developer is half decent you’ll also get comments right there next to the enum. You don’t need a tool to spit out a html page that you’ll host somewher. Most reasonable information can be part of the schema file, and that’s it.

All that said, everyone now is familiar with Json and rest. Because of that, small projects are better doing it. But that supremely will eventually end. And for large projects, graphql makes some things much easier, like types.