@@ -169,6 +169,8 @@ The GraphQL specification allows for many
169
169
Servers and clients MUST support JSON and MAY support other, additional
170
170
serialization formats.
171
171
172
+ Note: Allowing other media types, particularly on requests, can be insecure.
173
+
172
174
For consistency and ease of notation, examples of the response are given in JSON
173
175
throughout this specification.
174
176
@@ -240,9 +242,17 @@ A client SHOULD indicate the media types that it supports in responses using the
240
242
` Accept ` HTTP header as specified in
241
243
[ RFC7231] ( https://datatracker.ietf.org/doc/html/rfc7231 ) .
242
244
245
+ Note: If a client does not supply the ` Accept ` header then the server may
246
+ respond with an error, or with any content type it chooses. To ensure your
247
+ client gets something useful, it should indicate the media types it supports.
248
+
243
249
If the client supplies an ` Accept ` header, the client SHOULD include the media
244
250
type ` application/graphql+json ` in the ` Accept ` header.
245
251
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_ .
255
+
246
256
### Legacy Watershed
247
257
248
258
Before ` 2025-01-01T00:00:00Z ` , if the client supplies an ` Accept ` header, the
@@ -323,12 +333,20 @@ type (as indicated by the `Content-Type` header).
323
333
If the client does not supply a ` Content-Type ` header with a POST request, the
324
334
server SHOULD reject the request using the appropriate ` 4xx ` status code.
325
335
336
+ Note: Rejecting such requests encourages clients to supply a ` Content-Type `
337
+ header with every POST request. A server has the option to assume any media type
338
+ they wish when none is supplied, with the understanding that parsing the request
339
+ may fail.
340
+
326
341
A server MAY support POST requests encoded with and/or accepting other media
327
342
types.
328
343
329
344
If a client does not know the media types the server supports then it SHOULD
330
345
encode the request body in JSON (i.e. with ` Content-Type: application/json ` ).
331
346
347
+ Note: Request encoding with media type ` application/json ` is supported by every
348
+ compliant _ server_ .
349
+
332
350
### JSON Encoding
333
351
334
352
When encoded in JSON, a GraphQL-over-HTTP request is a JSON object (map), with
@@ -465,6 +483,9 @@ depending on the concrete error condition.
465
483
466
484
Note: Typically this will be the ` 400 ` (Bad Request) status code.
467
485
486
+ Note: This rule is "should" to maintain compatibility with legacy servers which
487
+ can return 200 status codes even when this type of error occurs.
488
+
468
489
Otherwise, the status codes depends on the media type with which the GraphQL
469
490
response will be served:
470
491
0 commit comments