⬡ GraphQL Intermediate

What is the GraphQL over HTTP spec?

Answer

The GraphQL over HTTP specification formalizes how GraphQL requests and responses should be transported over HTTP, bringing consistency across different server implementations. Key requirements: (1) POST requests: body must be JSON with query, optional variables and operationName. Content-Type: application/json. (2) GET requests: supported for queries only — parameters in query string. (3) Response format: must have Content-Type: application/graphql-response+json (new media type) for compliant implementations. (4) Status codes: 200 for success + partial errors, 400 for invalid queries, 401/403 for auth errors. (5) Application/json: for backwards compatibility. The spec (maintained by The Guild and community) allows clients to reliably work with any compliant server without server-specific adapters. GraphQL Yoga follows this spec strictly.