Skip to content

application/graphql-response+json MIME Type — Meaning, Usage & Examples

application/graphql-response+json
Extensions: .json Class: application Spec: GraphQL

application/graphql-response+json means: application/graphql-response+json is the media type defined by the GraphQL over HTTP specification for responses. It lets servers use proper HTTP status codes for errors while keeping the GraphQL data/errors envelope, improving caching and intermediary behavior compared with always-200 JSON. Application media types carry structured or binary data that a program consumes rather than a human reading raw bytes. The subtype tells the receiver exactly which parser, decoder or handler to invoke, so sending the correct Content-Type is part of the API contract: a mismatch makes servers reject the body with 415 Unsupported Media Type or clients mis-parse the payload. You will encounter application/graphql-response+json in contexts such as spec-compliant graphql over http responses; clients that negotiate the newer response media type via accept; servers distinguishing transport errors from graphql field errors. It is commonly associated with the file extension(s) .json. This type is part of the newer GraphQL-over-HTTP spec; older servers return application/json with HTTP 200 even for errors. Clients should send it in Accept and handle both, since support is not yet universal across GraphQL implementations.

Advertisement
Ad slot · ref-top

When you'll see application/graphql-response+json

  • Spec-compliant GraphQL over HTTP responses
  • Clients that negotiate the newer response media type via Accept
  • Servers distinguishing transport errors from GraphQL field errors

How to handle it

When handling an application type, set the Content-Type header explicitly on every request and response that carries a body, and advertise what you accept with the Accept header. Parse the payload with a library that matches the subtype rather than sniffing bytes, and validate the structure before trusting it. If a server returns 415, the declared type does not match what it expects — compare your header against the API documentation character for character, including parameters such as charset or boundary. As a final checklist for application types: register the exact subtype in your API documentation, validate incoming bodies against a schema before use, set X-Content-Type-Options: nosniff to stop MIME sniffing, and version your media types when the payload contract changes so old clients keep working.

Notes & gotchas

This type is part of the newer GraphQL-over-HTTP spec; older servers return application/json with HTTP 200 even for errors. Clients should send it in Accept and handle both, since support is not yet universal across GraphQL implementations.

Examples

HTTP
HTTP/1.1 200 OK
Content-Type: application/graphql-response+json
Content-Length: 96

Sample application/graphql-response+json content delivered with the correct Content-Type header.
curl
curl -i -H "Accept: application/graphql-response+json" https://api.example.com/v1/resource   # inspect the returned Content-Type
JavaScript (fetch)
const res = await fetch("/v1/resource", { headers: { Accept: "application/graphql-response+json" } });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();   // parsed structured payload
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource",
                   headers={"Accept": "application/graphql-response+json"}, timeout=10)
res.raise_for_status()
# confirm the server declared the expected type
assert res.headers["Content-Type"].startswith("application/graphql-response+json")
text = res.text   # decode/handle according to the type

Frequently asked questions

How does this differ from application/json for GraphQL?

It permits meaningful HTTP status codes (e.g. 400 for a malformed query) alongside the GraphQL envelope, whereas the legacy convention always returns 200. This helps caches and monitors treat errors correctly.

Do all GraphQL servers support it?

No — it is defined by the GraphQL over HTTP spec but adoption varies. Offer it in Accept and fall back to application/json handling for older servers.

What happens if I send the wrong application Content-Type?

Servers that validate media types answer 415 Unsupported Media Type, and clients may parse the body with the wrong decoder. Always set Content-Type to the registered type that matches your payload, and set Accept to the types you can handle.

Is application/octet-stream a safe default?

It means 'arbitrary binary bytes' and forces a download rather than inline handling. Use it only when the real type is unknown or you deliberately want a save-as dialog; otherwise declare the specific registered type.

How do I debug a 415 Unsupported Media Type response?

Compare the Content-Type you actually sent against what the endpoint documents, including parameters like charset and boundary. A 415 means the server refuses that media type; send the exact registered type it accepts and retry.

Advertisement
Ad slot · ref-in-article

Try the JSON Formatter

Beautify, validate and minify JSON with clear error messages.

Open tool →