4 ms·
HTTP2 and GraphQL solve different problems. HTTP2 solves the connection per concurrent request problem of HTTP. GraphQL solves for lower overall request count.
by abhorrence 7y ago
HTTP2 and GraphQL solve different problems. HTTP2 solves the connection per concurrent request problem of HTTP. GraphQL solves for lower overall request count.
With “just” HTTP2, you’d be doing one of the following:
- creating bespoke endpoints
- creating an adhoc GraphQL-like API
- introducing latency equal to the round trip latency multiplied by the number of layers the query is deep
- wongarsu 7y agoIf your problem is that getting the data from the API is slow, both GraphQL and HTTP2 solve your problem: HTTP2 allows you to send REST requests faster, both more concurrently and with faster round trip; GraphQL instead allows you to combine all your requests into a single request that takes a single round trip. GraphQL obviously provides a more complete solution (one request is better than many), but at the cost of a lot of complexity.
- eyelidlessness 7y ago> one request is better than many This is plainly not true. Web servers are designed to serve concurrent requests. So are databases. HTTP2 drastically improves the networking part of this. GraphQL offers a unified request-response object without needing to combine responses. It provides no guarantees about improved performance, particularly when the solution is automated and there's no way for a requester to reason about the performance implication of the queries they're issuing. It almost certainly provides worse performance than well designed RESTful endpoints requested concurrently.
- robjan 7y agoGraphQL also moves the N+1 problem (data fetching being dependent on other data that you are fetching) to the server side where latencies should theoretically be lower.