GraphQL 模式中的特殊字符
Special characters in GraphQL schema
是否有任何方法可以在 GraphQL 架构中启用特殊字符(例如,字段名称中的 /
、:
、@
)?
如果没有(我怀疑是这种情况),您是否知道修改 node.js 代码 (https://github.com/graphql/graphql-js) 以实现此类功能的相对最简单的方法是什么? ?
我建议不要这样做。 graphql-js 遵循 graphql 规范中规定的语法形式。这样的更改将脱离规范,您的模式将不再适用于 graphql 工具。解析器会抛出无效的模式,因为这些字符在 graphql 中具有特殊含义。
GraphQL 规范
Punctuator:: one of ! $ ( ) ... : = @ [ ] { | }
GraphQL documents include punctuation in order to describe structure. GraphQL is a data description language and not a programming language, therefore GraphQL lacks the punctuation often used to describe mathematical expressions.
http://facebook.github.io/graphql/#sec-Punctuators
Name :: /[_A-Za-z][_0-9A-Za-z]*/
GraphQL query documents are full of named things: operations, fields, arguments, directives, fragments, and variables. All names must follow the same grammatical form. Names in GraphQL are case‐sensitive. That is to say name, Name, and NAME all refer to different names. Underscores are significant, which means other_name and othername are two different names. Names in GraphQL are limited to this ASCII subset of possible characters to support interoperation with as many other systems as possible.
是否有任何方法可以在 GraphQL 架构中启用特殊字符(例如,字段名称中的 /
、:
、@
)?
如果没有(我怀疑是这种情况),您是否知道修改 node.js 代码 (https://github.com/graphql/graphql-js) 以实现此类功能的相对最简单的方法是什么? ?
我建议不要这样做。 graphql-js 遵循 graphql 规范中规定的语法形式。这样的更改将脱离规范,您的模式将不再适用于 graphql 工具。解析器会抛出无效的模式,因为这些字符在 graphql 中具有特殊含义。
GraphQL 规范
Punctuator:: one of ! $ ( ) ... : = @ [ ] { | }
GraphQL documents include punctuation in order to describe structure. GraphQL is a data description language and not a programming language, therefore GraphQL lacks the punctuation often used to describe mathematical expressions.
http://facebook.github.io/graphql/#sec-Punctuators
Name :: /[_A-Za-z][_0-9A-Za-z]*/
GraphQL query documents are full of named things: operations, fields, arguments, directives, fragments, and variables. All names must follow the same grammatical form. Names in GraphQL are case‐sensitive. That is to say name, Name, and NAME all refer to different names. Underscores are significant, which means other_name and othername are two different names. Names in GraphQL are limited to this ASCII subset of possible characters to support interoperation with as many other systems as possible.