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.
Previous
What is Relay and how does it differ from Apollo Client?
Next
How do you implement a DataLoader with batching and caching?
More GraphQL Questions
View all →- Intermediate How do you implement pagination in GraphQL?
- Intermediate What is the Relay specification in GraphQL?
- Intermediate How do you implement authorization in GraphQL resolvers?
- Intermediate What is graphql-shield and how does it work?
- Intermediate How do you implement real-time subscriptions with GraphQL?