• porkloin@lemmy.world
    link
    fedilink
    arrow-up
    5
    arrow-down
    1
    ·
    22 hours ago

    That’s true, but for a good reason. GraphQL is transport agnostic, so using HTTP status to represent errors doesn’t make sense. HTTP is just a carrier for GraphQL, and the status code represents whether or not the HTTP part was successful.

    • The_Decryptor@aussie.zone
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 hour ago

      Well no, the HTTP error codes are about the entire request, not just whether or not the actual header part was received and processed right.

      Like HTTP 403, HTTP only has a basic form of authentication built in, anything else needs the server to handle it externally (e.g. via session cookies). It wouldn’t make sense to send “HTTP 200” in response to trying to access a resource without being logged in just because the request was well formed.

    • Olap@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      19 hours ago

      If only that were true. They are intimately connected and to pretend otherwise is laughable to me

      • porkloin@lemmy.world
        link
        fedilink
        arrow-up
        6
        ·
        11 hours ago

        What do you mean? You can literally run GraphQL without HTTP. This isn’t just a GraphQL-ism, gRPC also does it https://grpc.io/docs/guides/status-codes/

        I understand that most people use GraphQL over HTTP and that from a developer perspective you’d rather have HTTP status codes like every other REST API. To which I’d say, why don’t you just use REST instead?

        There are a bunch of legitimate reasons why a clean separation of transport layer and application layer makes sense - you just aren’t using them so it feels like an arbitrary frustration to you.

        Have you ever run an application like a golang REST API behind an envoy or nginx proxy or load balancer and gotten an HTTP status 500 back and wrongly assumed it was coming from your application/golang code, only to later find it was a problem at the proxy or load balancer? If so, you’ve experienced the misdirection of combining transport and application layer being forced to share a status field. This isn’t a trivial example - time is wasted every day by developers misdiagnosing errors originating from transport as application errors, and vice versa.

        You might not like it, but separating them IS smart design.

        • Olap@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          8 hours ago

          Logs, logs, logs, you’ll pour over logs anyway. Hands up anyone who has run GraphQL over anything but http? Won’t be many. And then another show of hands please: who’s written a basic request using http tooling instead? Bet there’s tons!

          They threw away loads of tooling for the sake of vanity imo