graphql-over-http
graphql-over-http copied to clipboard
Allow non-UTF-8 encodings
The draft spec currently requires that UTF-8 is the one and only encoding supported by servers. See:
If the media type in a
Content-Type
orAccept
header includes encoding information, then the encoding MUST beutf-8
(e.g.Content-Type: application/graphql-response+json; charset=utf-8
). If encoding information is not included thenutf-8
MUST be assumed.
This is at odds with the initial paragraph which says that additional formats may be supported:
The GraphQL specification allows for many serialization formats to be implemented. Servers and clients MUST support JSON and MAY support other, additional serialization formats.
I suggest relaxing the former paragraph a bit to indicate that utf-8
MUST be supported by servers and SHOULD be used for requests, and MUST be assumed if not specified, similar to requirements for the media type used by requests/responses.
I know that one of our users that has a need for a different encoding for requests. So at present, GraphQL.NET supports any encoding supported by the underlying operating system for requests, while responses currently are only UTF-8. (Note that I believe the JSON string escaping used by default would be such that it would also be ASCII compatible -- but I'd have to check to be sure.)
cc: @sungam3r
That sounds reasonable; would you like to submit a PR?
If you like; perhaps this weekend I can do it.