@@ -270,12 +270,6 @@ export class Parser {
270270
271271 if ( keywordToken . kind === TokenKind . NAME ) {
272272 switch ( keywordToken . value ) {
273- case 'query' :
274- case 'mutation' :
275- case 'subscription' :
276- return this . parseOperationDefinition ( ) ;
277- case 'fragment' :
278- return this . parseFragmentDefinition ( ) ;
279273 case 'schema' :
280274 return this . parseSchemaDefinition ( ) ;
281275 case 'scalar' :
@@ -292,18 +286,37 @@ export class Parser {
292286 return this . parseInputObjectTypeDefinition ( ) ;
293287 case 'directive' :
294288 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 ( ) ;
295306 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- }
303307 return this . parseTypeSystemExtension ( ) ;
304308 }
305309 }
306310
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+
307320 throw this . unexpected ( keywordToken ) ;
308321 }
309322
0 commit comments