graphql-over-http icon indicating copy to clipboard operation
graphql-over-http copied to clipboard

Allow non-UTF-8 encodings

Open Shane32 opened this issue 1 year ago • 2 comments

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 or Accept header includes encoding information, then the encoding MUST be utf-8 (e.g. Content-Type: application/graphql-response+json; charset=utf-8). If encoding information is not included then utf-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

Shane32 avatar Sep 20 '22 02:09 Shane32

That sounds reasonable; would you like to submit a PR?

benjie avatar Sep 20 '22 07:09 benjie

If you like; perhaps this weekend I can do it.

Shane32 avatar Sep 21 '22 02:09 Shane32