问题
Is there any way of enabling special characters in GraphQL schema (e.g., /
, :
, @
in the field names)?
And if there isn't (which I suspect is the case) do you have an idea what would be relatively easiest way to modify the node.js code (https://github.com/graphql/graphql-js) to achieve such functionality?
回答1:
I would recommend against doing in this. graphql-js follows the grammatical form stated in the graphql specification. Such a change would be a break away from the specification and your schema would no longer work with graphql tools. The parser would throw an invalid schema because these characters have special meaning in graphql.
GraphQL Spec
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.
http://facebook.github.io/graphql/#sec-Names
来源:https://stackoverflow.com/questions/45756493/special-characters-in-graphql-schema