graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

请问字段可否支持多语言 Can the field support multiple languages?

Open Duanxs opened this issue 2 years ago • 2 comments

目前,Graphql 不支持中文字段,使用上略有不便。像 mysql、mongoDB 均支持多语言字段名,希望 Graphql 也跟进,以方便全球各语言用户。

machine translation: Currently, Graphql does not support Chinese fields, which is slightly inconvenient. Like mysql and mongoDB, they support multilingual field names, and I hope that Graphql will follow suit to facilitate users in various languages around the world.

报错样例:

type 用户 {
    姓名: String!
}
GraphQLError: Syntax Error: Unexpected character: U+7528.
    at syntaxError (/path/node_modules/.pnpm/[email protected]/node_modules/graphql/error/syntaxError.js:15:10)
    at readNextToken (/path/node_modules/.pnpm/[email protected]/node_modules/graphql/language/lexer.js:420:28)
...

Duanxs avatar Jul 07 '23 07:07 Duanxs

there have been many discussion and progress being made to support for Unicode

  • https://github.com/graphql/graphql-spec/issues/256
  • https://github.com/graphql/graphql-spec/issues/687
  • https://github.com/graphql/graphql-js/pull/3117
  • https://github.com/graphql/graphql-js/pull/3322

saihaj avatar Jul 07 '23 10:07 saihaj

The main issue has been open for 8 years so I wouldn’t count on it.

Edit: If you don’t mind a hacky approach, you can use this patch.

alex-kinokon avatar Jul 12 '23 04:07 alex-kinokon