@@ -62,27 +62,35 @@ typeCondition : 'on' typeName;
6262name : NAME | FRAGMENT | QUERY | MUTATION | SUBSCRIPTION | SCHEMA | SCALAR | TYPE | INTERFACE | IMPLEMENTS | ENUM | UNION | INPUT | EXTEND | DIRECTIVE ;
6363
6464value :
65+ stringValue |
6566IntValue |
6667FloatValue |
67- StringValue |
6868BooleanValue |
6969NullValue |
7070enumValue |
7171arrayValue |
7272objectValue ;
7373
74+
7475valueWithVariable :
7576variable |
77+ stringValue |
7678IntValue |
7779FloatValue |
78- StringValue |
7980BooleanValue |
8081NullValue |
8182enumValue |
8283arrayValueWithVariable |
8384objectValueWithVariable ;
8485
8586
87+ stringValue
88+ : TripleQuotedStringValue
89+ | StringValue
90+ ;
91+
92+ description : stringValue;
93+
8694enumValue : name ;
8795
8896// Array Value
@@ -115,16 +123,16 @@ nonNullType: typeName '!' | listType '!';
115123
116124
117125// Type System
118- typeSystemDefinition :
126+ typeSystemDefinition : description?
119127schemaDefinition |
120128typeDefinition |
121129typeExtensionDefinition |
122130directiveDefinition
123131;
124132
125- schemaDefinition : SCHEMA directives? ' {' operationTypeDefinition+ ' }' ;
133+ schemaDefinition : description? SCHEMA directives? ' {' operationTypeDefinition+ ' }' ;
126134
127- operationTypeDefinition : operationType ' :' typeName;
135+ operationTypeDefinition : description? operationType ' :' typeName;
128136
129137typeDefinition :
130138scalarTypeDefinition |
@@ -135,36 +143,40 @@ enumTypeDefinition |
135143inputObjectTypeDefinition
136144;
137145
138- scalarTypeDefinition : SCALAR name directives?;
146+ scalarTypeDefinition : description? SCALAR name directives?;
139147
140- objectTypeDefinition : TYPE name implementsInterfaces? directives? ' {' fieldDefinition+ ' }' ;
148+ objectTypeDefinition : description? TYPE name implementsInterfaces? directives? ' {' fieldDefinition+ ' }' ;
141149
142150implementsInterfaces : IMPLEMENTS typeName+;
143151
144- fieldDefinition : name argumentsDefinition? ' :' type directives?;
152+ fieldDefinition : description? name argumentsDefinition? ' :' type directives?;
145153
146154argumentsDefinition : ' (' inputValueDefinition+ ' )' ;
147155
148- inputValueDefinition : name ' :' type defaultValue? directives?;
156+ inputValueDefinition : description? name ' :' type defaultValue? directives?;
149157
150- interfaceTypeDefinition : INTERFACE name directives? ' {' fieldDefinition+ ' }' ;
158+ interfaceTypeDefinition : description? INTERFACE name directives? ' {' fieldDefinition+ ' }' ;
151159
152- unionTypeDefinition : UNION name directives? ' =' unionMembers;
160+ unionTypeDefinition : description? UNION name directives? ' =' unionMembers;
153161
154162unionMembers :
155163typeName |
156164unionMembers ' |' typeName
157165;
158166
159- enumTypeDefinition : ENUM name directives? ' {' enumValueDefinition+ ' }' ;
167+ enumTypeDefinition : description? ENUM name directives? ' {' enumValueDefinition+ ' }' ;
160168
161- enumValueDefinition : enumValue directives?;
169+ enumValueDefinition : description? enumValue directives?;
162170
163- inputObjectTypeDefinition : INPUT name directives? ' {' inputValueDefinition+ ' }' ;
171+ inputObjectTypeDefinition : description? INPUT name directives? ' {' inputValueDefinition+ ' }' ;
164172
173+ //
174+ // type extensions dont get "description" strings according to reference implementation
175+ // https://github.com/graphql/graphql-js/pull/927/files#diff-b9370666fe8cd9ff4dd53e89e60d26afR182
176+ //
165177typeExtensionDefinition : EXTEND objectTypeDefinition;
166178
167- directiveDefinition : DIRECTIVE ' @' name argumentsDefinition? ' on' directiveLocations;
179+ directiveDefinition : description? DIRECTIVE ' @' name argumentsDefinition? ' on' directiveLocations;
168180
169181directiveLocation : name;
170182
@@ -212,7 +224,19 @@ ExponentPart : ('e'|'E') Sign? Digit+;
212224Digit : ' 0' ..' 9' ;
213225
214226
215- StringValue : ' "' (~([" \\\n\r\u2028\u2029 ])|EscapedChar)* '" ' ;
227+ StringValue
228+ : ' "' ( ~[" \\\n\r\u2028\u2029 ] | EscapedChar )* '" '
229+ ;
230+
231+ TripleQuotedStringValue
232+ : ' " " " ' TripleQuotedStringPart? '" " " '
233+ ;
234+
235+
236+ // Fragments never become a token of their own: they are only used inside other lexer rules
237+ fragment TripleQuotedStringPart : ( EscapedTripleQuote | SourceCharacter )+?;
238+ fragment EscapedTripleQuote : ' \\" " " ';
239+ fragment SourceCharacter :[\u0009\u000A\u000D\u0020 -\uFFFF ];
216240
217241Comment: '#' ~[\n\r\u2028\u2029 ]* -> channel(2);
218242
0 commit comments