4 ms·
Like HTTP statuses then? I'd still rather have them than not. (And I'll still be annoyed by GraphQL saying 200 OK - here're your errors!)
by OJFord 5y ago
Like HTTP statuses then? I'd still rather have them than not. (And I'll still be annoyed by GraphQL saying 200 OK - here're your errors!)
- Quekid5 5y agoAt least HTTP status codes can reasonably point to where the error is: 2xx - Fine, you get to decide what to do 4xx - Problem on your end, mate 5xx - Problem on our end. Sorry, mate 3xx - It's complicated... GraphQL responding 200 to erroneous queries is... surprising (assuming only HTTP semantics), but what kind of errors were these? Of course, we're assuming servers implemented by at least semi-reasonable people. EDIT: That said, I'd actually be happy with a protocol-level 2, 4, 5, 3 and leaving the rest up the application layer. I know that isn't very HATEOAS, but in practice all people truly want is RPC. (Sadly.)
- derefr 5y ago> GraphQL responding 200 to erroneous queries is... surprising To me, both GraphQL (and also JSON-RPC, another weird one for HTTP errors) are really application-layer protocols of their own that are just "spoken over" HTTP, and as such implement their own error signalling standards. In cases like that, an HTTP error doesn't pertain to anything being discussed "inside" the overlay protocol; but instead refers to the carrier protocol. For example, seeing an HTTP 404 in response to hitting a GraphQL or JSON-RPC endpoint, wouldn't mean that the resource you asked for with your overlay-protocol request doesn't exist, but rather that the endpoint you wanted to speak the overlay protocol to doesn't exist. Consider, by analogy: a websocket, which actually does speak a formal HTTP sub-protocol. If you make the right request, you get your HTTP connection upgraded into a WebSocket connection. If you don't? Carrier protocol error.
- masklinn 5y agoIndeed, both GraphQL and JSON-RPC use HTTP as a simple pipe: * JSON-RPC has no dependency on HTTP, you can use it over regular sockets or websocket (that's exactly what the Chrome DevTools Protocol does). That is why JSON-RPC has a concept of "request ids", similar to protocols like IMAP: it was designed for compatibility with full-duplex communications and asynchronous results (rather than strict request/response). * GraphQL's semantics are not strictly fitting within HTTP, what with being able to send multiple queries in the same request (which is a different proposition than sending concurrent requests, even when pipelining, when it comes to server resources).
- nerdponx 5y agoI learned about this recently and have never been more disgusted with a software design decision. Why??
- OJFord 5y agoIt makes sense in a 'technically true but ugh' sort of way. The GQL server is saying it successfully executed that query, here is the response, it happens to contain an error. And in further fairness, I believe there can be multiple 'responses' within, some of which may be errors and others not. But still ugh, personally I'd rather have resource-oriented semantic HTTP (read: 'REST' without triggering empassioned debate) just for that. I don't think adds enough over HTTP to warrant this sort of weirdness (sibling comment describes it as the next layer) - if it were just an HTTP alternative sitting on TCP fine, and I'm sure it would happily not have a top-level status code (or a more meaningful one) itself anyway.
- derefr 5y ago> and I'm sure it would happily not have a top-level status code (or a more meaningful one) itself anyway Fun thing to learn about: WebDAV introduced the HTTP 207 "Multi-Status" response status, for precisely the case where the response is actually a multi-response envelope. https://httpstatuses.com/207 https://httpstatuses.com/207 I often feel that the extra methods and features introduced by WebDAV would be usefully generalized to other analogous use-cases, like GraphQL. But then I recall that most of the WebDAV-specific stuff specifies XML-based request/response message formats, and quickly give up on the idea of any modern programmer doing it as a cool hack. Can't have "cool hack" and "XML" in the same sentence, after all ;)