Announcing the GraphQL over HTTP specification
In 2015, the GraphQL specification was launched, emphasizing its transport-agnostic nature. The foundation of the GraphQL specification revolves around "services" that accept "requests," process them, and return "responses." The method through which these requests and responses are transmitted is determined by the implementer, offering flexibility.
While this approach proves advantageous for local testing and diverse use cases, it poses challenges for those frequently utilizing GraphQL over HTTP. Lack of a standardized protocol hinders interoperability with other HTTP tools and hampers observability for those implementing GraphQL over HTTP.
The recent announcement of the GraphQL over HTTP specification aims to resolve these issues. This new document serves as a supplementary guide to the main GraphQL specification, ensuring seamless compatibility among servers, clients, proxies, and other services. The specification introduces the application/graphql-response+json media type, replacing the widely used application/json format for responses.
This change addresses the issue of distinguishing between well-formed GraphQL responses and error responses from network intermediaries. In the new specification, clients can parse an application/graphql-response+json body as a valid GraphQL over HTTP response, irrespective of the status code.
The specification elaborates on the appropriate use of status codes, including the introduction of a new 294 Partial Success status code. This code is particularly useful when both data and errors are present, offering a more nuanced response than the commonly used 200 status code. The specification also touches upon security considerations, future compatibility, persisted queries, and request batching.
These additions aim to enhance the overall functionality and reliability of GraphQL over HTTP, fostering a more standardized and efficient approach to implementing GraphQL over HTTP.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.