@@ -185,17 +185,17 @@ using the JSON encoding for GraphQL requests:
185
185
186
186
And for GraphQL responses:
187
187
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) |
192
192
193
193
For details of the shapes of these JSON payloads, please see
194
194
[ Request] ( #sec-Request ) and [ Response] ( #sec-Response ) .
195
195
196
196
If the media type in a ` Content-Type ` or ` Accept ` header includes encoding
197
197
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
199
199
information is not included then ` utf-8 ` MUST be assumed.
200
200
201
201
# Request
@@ -247,11 +247,11 @@ respond with an error, or with any content type it chooses. To ensure your
247
247
client gets something useful, it should indicate the media types it supports.
248
248
249
249
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.
251
251
252
252
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_ .
255
255
256
256
### Legacy Watershed
257
257
@@ -260,7 +260,7 @@ header SHOULD include the `application/json` media type. After this watershed,
260
260
this is no longer necessary.
261
261
262
262
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 ` .
264
264
265
265
Note: This recommended header enables compatibility with legacy servers whilst
266
266
still leveraging modern features if available in the server.
@@ -385,7 +385,7 @@ encoding with the headers:
385
385
386
386
``` headers example
387
387
Content-Type: application/json
388
- Accept: application/graphql+json
388
+ Accept: application/graphql-response +json
389
389
```
390
390
391
391
And the body:
@@ -435,29 +435,30 @@ in the `Accept` HTTP header, the server MUST either:
435
435
A server MUST support requests which accept the ` application/json ` media type
436
436
(as indicated by the ` Accept ` header).
437
437
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).
440
441
441
442
Note: Prior to this specification, the media type ` application/json ` was in wide
442
443
use for the HTTP response payload type. Unfortunately this means clients cannot
443
444
trust responses from the server that do not use an HTTP 2xx status code (since
444
445
these replies may come from non-compliant HTTP servers or proxies somewhere in
445
446
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
448
449
January 2025.
449
450
450
451
### Legacy watershed
451
452
452
453
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).
455
456
456
457
Before 1st January 2025 (` 2025-01-01T00:00:00Z ` ), if the client does not supply
457
458
an ` Accept ` header, the server SHOULD treat the request as if it had
458
459
` Accept: application/json ` . From 1st January 2025 (` 2025-01-01T00:00:00Z ` ), if
459
460
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 ` .
461
462
462
463
Note: This default is in place to maintain compatibility with legacy clients.
463
464
@@ -516,12 +517,13 @@ The server SHOULD NOT use a `4xx` or `5xx` status code.
516
517
Note: For compatibility with legacy servers, this specification allows the use
517
518
of ` 4xx ` or ` 5xx ` status codes for failed requests where the response uses the
518
519
` 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.
520
522
521
- ### application/graphql+json
523
+ ### application/graphql-response +json
522
524
523
525
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.
525
527
526
528
If the GraphQL response contains the {data} entry and it is not {null}, then the
527
529
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.
562
564
#### Examples
563
565
564
566
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:
567
569
568
570
##### JSON parsing failure
569
571
0 commit comments