@@ -270,12 +270,6 @@ export class Parser {
270
270
271
271
if ( keywordToken . kind === TokenKind . NAME ) {
272
272
switch ( keywordToken . value ) {
273
- case 'query' :
274
- case 'mutation' :
275
- case 'subscription' :
276
- return this . parseOperationDefinition ( ) ;
277
- case 'fragment' :
278
- return this . parseFragmentDefinition ( ) ;
279
273
case 'schema' :
280
274
return this . parseSchemaDefinition ( ) ;
281
275
case 'scalar' :
@@ -292,18 +286,37 @@ export class Parser {
292
286
return this . parseInputObjectTypeDefinition ( ) ;
293
287
case 'directive' :
294
288
return this . parseDirectiveDefinition ( ) ;
289
+ }
290
+
291
+ if ( hasDescription && keywordToken . value === 'extend' ) {
292
+ throw syntaxError (
293
+ this . _lexer . source ,
294
+ this . _lexer . token . start ,
295
+ 'Unexpected description, descriptions are not supported on type extensions.' ,
296
+ ) ;
297
+ }
298
+
299
+ switch ( keywordToken . value ) {
300
+ case 'query' :
301
+ case 'mutation' :
302
+ case 'subscription' :
303
+ return this . parseOperationDefinition ( ) ;
304
+ case 'fragment' :
305
+ return this . parseFragmentDefinition ( ) ;
295
306
case 'extend' :
296
- if ( hasDescription ) {
297
- throw syntaxError (
298
- this . _lexer . source ,
299
- this . _lexer . token . start ,
300
- 'Unexpected description, descriptions are not supported on type extensions.' ,
301
- ) ;
302
- }
303
307
return this . parseTypeSystemExtension ( ) ;
304
308
}
305
309
}
306
310
311
+ // Check for shorthand query with description
312
+ if ( hasDescription && keywordToken . kind === TokenKind . BRACE_L ) {
313
+ throw syntaxError (
314
+ this . _lexer . source ,
315
+ this . _lexer . token . start ,
316
+ 'Unexpected description, descriptions are not supported on shorthand queries.' ,
317
+ ) ;
318
+ }
319
+
307
320
throw this . unexpected ( keywordToken ) ;
308
321
}
309
322
0 commit comments