@@ -113,6 +113,18 @@ export interface ParseOptions {
113113 */
114114 allowLegacyFragmentVariables ?: boolean ;
115115
116+ /**
117+ * EXPERIMENTAL:
118+ *
119+ * If enabled, the parser will parse directives on directive definitions.
120+ * This syntax is not part of the GraphQL specification and may change.
121+ *
122+ * ```graphql
123+ * directive @foo @bar on FIELD
124+ * ```
125+ */
126+ experimentalDirectivesOnDirectiveDefinitions ?: boolean ;
127+
116128 /**
117129 * You may override the Lexer class used to lex the source; this is used by
118130 * schema coordinates to introduce a lexer with a restricted syntax.
@@ -1207,7 +1219,12 @@ export class Parser {
12071219 case 'input' :
12081220 return this . parseInputObjectTypeExtension ( ) ;
12091221 case 'directive' :
1210- return this . parseDirectiveDefinitionExtension ( ) ;
1222+ if (
1223+ this . _options . experimentalDirectivesOnDirectiveDefinitions === true
1224+ ) {
1225+ return this . parseDirectiveDefinitionExtension ( ) ;
1226+ }
1227+ break ;
12111228 }
12121229 }
12131230
@@ -1420,7 +1437,10 @@ export class Parser {
14201437 this . expectToken ( TokenKind . AT ) ;
14211438 const name = this . parseName ( ) ;
14221439 const args = this . parseArgumentDefs ( ) ;
1423- const directives = this . parseConstDirectives ( ) ;
1440+ const directives =
1441+ this . _options . experimentalDirectivesOnDirectiveDefinitions === true
1442+ ? this . parseConstDirectives ( )
1443+ : [ ] ;
14241444 const repeatable = this . expectOptionalKeyword ( 'repeatable' ) ;
14251445 this . expectKeyword ( 'on' ) ;
14261446 const locations = this . parseDirectiveLocations ( ) ;
0 commit comments