Skip to content

clarify that utf-8 is just a possible encoding of strings #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,16 @@ outside the available precision), a request error must be raised.

### String

The String scalar type represents textual data, represented as UTF-8 character
sequences. The String type is most often used by GraphQL to represent free-form
human-readable text. All response formats must support string representations,
and that representation must be used here.
The String scalar type represents textual data, represented as a sequence of
Unicode code points. The String type is most often used by GraphQL to
represent free-form human-readable text. How the String is encoded internally
(for example UTF-8) is left to the service implementation. All response
serialization formats must support a string representation (for example, JSON
Unicode strings), and that representation must be used to serialize this type.

**Result Coercion**

Fields returning the type {String} expect to encounter UTF-8 string internal values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part should continue to specify UTF-8? As I read it, it's about the serialization of strings in responses, where specifying an encoding is actually appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is about result coercion not serialization. Of course String can be serialized to UTF-8 (and often they are via UTF-8 JSON) but it doesn't have to be.

Fields returning the type {String} expect to encounter Unicode string values.

GraphQL services may coerce non-string raw values to {String} when reasonable
without losing information, otherwise they must raise a field error. Examples of
Expand All @@ -545,7 +547,7 @@ string `"1"` for the integer `1`.

**Input Coercion**

When expected as an input type, only valid UTF-8 string input values are
When expected as an input type, only valid Unicode string input values are
accepted. All other input values must raise a request error indicating an
incorrect type.

Expand Down