Skip to content

Commit 4b8ea34

Browse files
Shane32benjie
andauthored
Clarify support of UTF-8 and other encodings (#232)
* Clarify support of UTF-8 and other encodings See #229 * Update GraphQLOverHTTP.md * Update INTERESTED_DEVELOPERS.md * Update GraphQLOverHTTP.md * Update spec/GraphQLOverHTTP.md Co-authored-by: Benjie <[email protected]> * Update GraphQLOverHTTP.md * Update GraphQLOverHTTP.md * Update spec/GraphQLOverHTTP.md * Update spec/GraphQLOverHTTP.md Co-authored-by: Benjie <[email protected]> * Update spec/GraphQLOverHTTP.md Co-authored-by: Benjie <[email protected]> * Update spec/GraphQLOverHTTP.md Co-authored-by: Benjie <[email protected]> * Apply suggestions from code review * Update formatting --------- Co-authored-by: Benjie <[email protected]>
1 parent 7fd6c72 commit 4b8ea34

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

spec/GraphQLOverHTTP.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,11 @@ And for a _GraphQL response_:
193193
For details of the shapes of these JSON payloads, please see
194194
[Request](#sec-Request) and [Response](#sec-Response).
195195

196-
If the media type in a `Content-Type` or `Accept` header includes encoding
197-
information, then the encoding MUST be `utf-8` (e.g.
198-
`Content-Type: application/graphql-response+json; charset=utf-8`). If encoding
199-
information is not included then `utf-8` MUST be assumed.
196+
If the media type in a `Content-Type` or `Accept` header does not include
197+
encoding information and matches one of the officially recognized GraphQL media
198+
types, then `utf-8` MUST be assumed (e.g. for header
199+
`Content-Type: application/graphql-response+json`, UTF-8 encoding would be
200+
assumed).
200201

201202
# Request
202203

@@ -328,7 +329,10 @@ A client MUST indicate the media type of a request body using the `Content-Type`
328329
header as specified in [RFC7231](https://datatracker.ietf.org/doc/html/rfc7231).
329330

330331
A server MUST support POST requests encoded with the `application/json` media
331-
type (as indicated by the `Content-Type` header).
332+
type (as indicated by the `Content-Type` header) encoded with UTF-8.
333+
334+
For POST requests using an officially recognized GraphQL `Content-Type` without
335+
indicating an encoding, the server MUST assume the encoding is `utf-8`.
332336

333337
If the client does not supply a `Content-Type` header with a POST request, the
334338
server SHOULD reject the request using the appropriate `4xx` status code.
@@ -339,7 +343,7 @@ they wish when none is supplied, with the understanding that parsing the request
339343
may fail.
340344

341345
A server MAY support POST requests encoded with and/or accepting other media
342-
types.
346+
types or encodings.
343347

344348
If a client does not know the media types the server supports then it SHOULD
345349
encode the request body in JSON (i.e. with `Content-Type: application/json`).
@@ -415,7 +419,8 @@ The body of the server's response MUST follow the requirements for a
415419
[GraphQL response](#sec-Response), encoded directly in the chosen media type.
416420

417421
A server MUST indicate the media type of the response with a `Content-Type`
418-
header.
422+
header, and SHOULD indicate the encoding (e.g.
423+
`application/graphql-response+json; charset=utf-8`).
419424

420425
If an `Accept` header is provided, the server MUST respect the given `Accept`
421426
header and attempt to encode the response in the highest priority media type
@@ -451,7 +456,7 @@ January 2025.
451456

452457
From 1st January 2025 (`2025-01-01T00:00:00Z`), a server MUST support requests
453458
which accept the `application/graphql-response+json` media type (as indicated by
454-
the `Accept` header).
459+
the `Accept` header) using the UTF-8 encoding.
455460

456461
Before 1st January 2025 (`2025-01-01T00:00:00Z`), if the client does not supply
457462
an `Accept` header, the server SHOULD treat the request as if it had

0 commit comments

Comments
 (0)