GraphQL模式中的特殊字符 [英] Special characters in GraphQL schema

查看:129
本文介绍了GraphQL模式中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在GraphQL模式中启用特殊字符(例如,字段名称中的/:@)?

Is there any way of enabling special characters in GraphQL schema (e.g., /, :, @ in the field names)?

如果没有(我怀疑是这种情况),您是否有一种相对最简单的修改node.js代码的方法(

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?

推荐答案

我建议您不要这样做. graphql-js遵循graphql规范中规定的语法形式.这样的更改将是对规范的一种破坏,并且您的架构将不再适用于graphql工具.解析器将抛出无效的架构,因为这些字符在graphql中具有特殊含义.

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规范

打孔器 ::之一! $()...:= @ [] {| }
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

名称 ::/[_ A-Za-z] [_ 0-9A-Za-z] */
GraphQL查询文档充满了命名的事物:操作,字段,参数,指令,片段和变量.所有名称必须遵循相同的语法形式. GraphQL中的名称区分大小写.也就是说,名称,名称和名称全都指代不同的名称.下划线是有效的,这意味着other_name和othername是两个不同的名称. GraphQL中的名称仅限于可能字符的ASCII子集,以支持与尽可能多的其他系统的互操作.

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

这篇关于GraphQL模式中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆