Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters in GraphQL schema

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?

like image 396
szymon Avatar asked Aug 18 '17 12:08

szymon


People also ask

What is exclamation mark in GraphQL?

means that the field is non-nullable, meaning that the GraphQL service promises to always give you a value when you query this field. In the type language, we'll represent those with an exclamation mark.

Is GraphQL case sensitive?

Names in GraphQL are case‐sensitive. That is to say name , Name , and NAME all refer to different names.

What is __ Typename in GraphQL?

The __typename field returns the object type's name as a String (e.g., Book or Author ). GraphQL clients use an object's __typename for many purposes, such as to determine which type was returned by a field that can return multiple types (i.e., a union or interface).


1 Answers

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

like image 94
otissv Avatar answered Oct 23 '22 10:10

otissv