Skip to content

Commit 37f5d2c

Browse files
authored
Change media type to 'application/graphql-response+json' (#215)
1 parent 62d7315 commit 37f5d2c

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

spec/GraphQLOverHTTP.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ using the JSON encoding for GraphQL requests:
185185

186186
And for GraphQL responses:
187187

188-
| Name | Description |
189-
| -------------------------- | ------------------------------------------------------------------ |
190-
| `application/graphql+json` | The preferred type for server responses; better HTTP compatibility |
191-
| `application/json` | An alternative type for responses (to support legacy clients) |
188+
| Name | Description |
189+
| ----------------------------------- | ------------------------------------------------------------------ |
190+
| `application/graphql-response+json` | The preferred type for server responses; better HTTP compatibility |
191+
| `application/json` | An alternative type for responses (to support legacy clients) |
192192

193193
For details of the shapes of these JSON payloads, please see
194194
[Request](#sec-Request) and [Response](#sec-Response).
195195

196196
If the media type in a `Content-Type` or `Accept` header includes encoding
197197
information, then the encoding MUST be `utf-8` (e.g.
198-
`Content-Type: application/graphql+json; charset=utf-8`). If encoding
198+
`Content-Type: application/graphql-response+json; charset=utf-8`). If encoding
199199
information is not included then `utf-8` MUST be assumed.
200200

201201
# Request
@@ -247,11 +247,11 @@ respond with an error, or with any content type it chooses. To ensure your
247247
client gets something useful, it should indicate the media types it supports.
248248

249249
If the client supplies an `Accept` header, the client SHOULD include the media
250-
type `application/graphql+json` in the `Accept` header.
250+
type `application/graphql-response+json` in the `Accept` header.
251251

252252
Note: From 1st Jan 2025, every _server_ and _client_ must support
253-
`application/graphql+json`, so including this in the Accept header should give
254-
your client compatibility with any _server_.
253+
`application/graphql-response+json`, so including this in the Accept header
254+
should give your client compatibility with any _server_.
255255

256256
### Legacy Watershed
257257

@@ -260,7 +260,7 @@ header SHOULD include the `application/json` media type. After this watershed,
260260
this is no longer necessary.
261261

262262
It is RECOMMENDED that a client set the `Accept` header to
263-
`application/graphql+json; charset=utf-8, application/json; charset=utf-8`.
263+
`application/graphql-response+json; charset=utf-8, application/json; charset=utf-8`.
264264

265265
Note: This recommended header enables compatibility with legacy servers whilst
266266
still leveraging modern features if available in the server.
@@ -385,7 +385,7 @@ encoding with the headers:
385385

386386
```headers example
387387
Content-Type: application/json
388-
Accept: application/graphql+json
388+
Accept: application/graphql-response+json
389389
```
390390

391391
And the body:
@@ -435,29 +435,30 @@ in the `Accept` HTTP header, the server MUST either:
435435
A server MUST support requests which accept the `application/json` media type
436436
(as indicated by the `Accept` header).
437437

438-
A server SHOULD support requests which accept the `application/graphql+json`
439-
media type (as indicated by the `Accept` header).
438+
A server SHOULD support requests which accept the
439+
`application/graphql-response+json` media type (as indicated by the `Accept`
440+
header).
440441

441442
Note: Prior to this specification, the media type `application/json` was in wide
442443
use for the HTTP response payload type. Unfortunately this means clients cannot
443444
trust responses from the server that do not use an HTTP 2xx status code (since
444445
these replies may come from non-compliant HTTP servers or proxies somewhere in
445446
the request chain). For this reason, this specification introduces the
446-
`application/graphql+json` media type on responses; however, to give existing
447-
servers time to move over, it is not required to be supported until 1st
447+
`application/graphql-response+json` media type on responses; however, to give
448+
existing servers time to move over, it is not required to be supported until 1st
448449
January 2025.
449450

450451
### Legacy watershed
451452

452453
From 1st January 2025 (`2025-01-01T00:00:00Z`), a server MUST support requests
453-
which accept the `application/graphql+json` media type (as indicated by the
454-
`Accept` header).
454+
which accept the `application/graphql-response+json` media type (as indicated by
455+
the `Accept` header).
455456

456457
Before 1st January 2025 (`2025-01-01T00:00:00Z`), if the client does not supply
457458
an `Accept` header, the server SHOULD treat the request as if it had
458459
`Accept: application/json`. From 1st January 2025 (`2025-01-01T00:00:00Z`), if
459460
the client does not supply an `Accept` header, the server SHOULD treat the
460-
request as if it had `Accept: application/graphql+json`.
461+
request as if it had `Accept: application/graphql-response+json`.
461462

462463
Note: This default is in place to maintain compatibility with legacy clients.
463464

@@ -516,12 +517,13 @@ The server SHOULD NOT use a `4xx` or `5xx` status code.
516517
Note: For compatibility with legacy servers, this specification allows the use
517518
of `4xx` or `5xx` status codes for failed requests where the response uses the
518519
`application/json` media type, but it is strongly discouraged. To use `4xx` and
519-
`5xx` status codes, please use the `application/graphql+json` media type.
520+
`5xx` status codes, please use the `application/graphql-response+json` media
521+
type.
520522

521-
### application/graphql+json
523+
### application/graphql-response+json
522524

523525
This section only applies when the response body is to use the
524-
`application/graphql+json` media type.
526+
`application/graphql-response+json` media type.
525527

526528
If the GraphQL response contains the {data} entry and it is not {null}, then the
527529
server MUST reply with a `2xx` status code and SHOULD reply with `200` status
@@ -562,8 +564,8 @@ SHOULD reply with `403`, `401` or similar appropriate status code.
562564
#### Examples
563565

564566
The following examples provide guidance on how to deal with specific error cases
565-
when using the `application/graphql+json` media type to encode the response
566-
body:
567+
when using the `application/graphql-response+json` media type to encode the
568+
response body:
567569

568570
##### JSON parsing failure
569571

0 commit comments

Comments
 (0)