graphql 16.13.2 → 16.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/index.d.ts +1 -0
  2. package/language/ast.d.ts +10 -1
  3. package/language/ast.js +8 -1
  4. package/language/ast.mjs +8 -1
  5. package/language/directiveLocation.d.ts +1 -0
  6. package/language/directiveLocation.js +1 -0
  7. package/language/directiveLocation.mjs +1 -0
  8. package/language/index.d.ts +1 -0
  9. package/language/kinds.d.ts +1 -0
  10. package/language/kinds.js +1 -0
  11. package/language/kinds.mjs +1 -0
  12. package/language/parser.d.ts +14 -0
  13. package/language/parser.js +33 -0
  14. package/language/parser.mjs +33 -0
  15. package/language/predicates.js +3 -1
  16. package/language/predicates.mjs +5 -1
  17. package/language/printer.js +13 -1
  18. package/language/printer.mjs +13 -1
  19. package/package.json +1 -1
  20. package/type/directives.d.ts +9 -1
  21. package/type/directives.js +10 -1
  22. package/type/directives.mjs +10 -1
  23. package/type/introspection.js +24 -1
  24. package/type/introspection.mjs +24 -1
  25. package/utilities/buildASTSchema.js +4 -0
  26. package/utilities/buildASTSchema.mjs +4 -0
  27. package/utilities/buildClientSchema.js +1 -0
  28. package/utilities/buildClientSchema.mjs +1 -0
  29. package/utilities/extendSchema.js +58 -3
  30. package/utilities/extendSchema.mjs +58 -3
  31. package/utilities/getIntrospectionQuery.d.ts +16 -0
  32. package/utilities/getIntrospectionQuery.js +31 -38
  33. package/utilities/getIntrospectionQuery.mjs +31 -38
  34. package/utilities/introspectionFromSchema.js +1 -0
  35. package/utilities/introspectionFromSchema.mjs +1 -0
  36. package/utilities/printSchema.js +1 -0
  37. package/utilities/printSchema.mjs +1 -0
  38. package/utilities/valueFromAST.js +12 -2
  39. package/utilities/valueFromAST.mjs +12 -2
  40. package/validation/rules/KnownDirectivesRule.js +4 -0
  41. package/validation/rules/KnownDirectivesRule.mjs +4 -0
  42. package/validation/rules/UniqueDirectivesPerLocationRule.js +12 -0
  43. package/validation/rules/UniqueDirectivesPerLocationRule.mjs +12 -0
  44. package/version.js +3 -3
  45. package/version.mjs +3 -3
package/index.d.ts CHANGED
@@ -280,6 +280,7 @@ export type {
280
280
  UnionTypeExtensionNode,
281
281
  EnumTypeExtensionNode,
282
282
  InputObjectTypeExtensionNode,
283
+ DirectiveExtensionNode,
283
284
  SchemaCoordinateNode,
284
285
  TypeCoordinateNode,
285
286
  MemberCoordinateNode,
package/language/ast.d.ts CHANGED
@@ -135,6 +135,7 @@ export declare type ASTNode =
135
135
  | UnionTypeExtensionNode
136
136
  | EnumTypeExtensionNode
137
137
  | InputObjectTypeExtensionNode
138
+ | DirectiveExtensionNode
138
139
  | TypeCoordinateNode
139
140
  | MemberCoordinateNode
140
141
  | ArgumentCoordinateNode
@@ -480,13 +481,15 @@ export interface DirectiveDefinitionNode {
480
481
  readonly description?: StringValueNode;
481
482
  readonly name: NameNode;
482
483
  readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
484
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
483
485
  readonly repeatable: boolean;
484
486
  readonly locations: ReadonlyArray<NameNode>;
485
487
  }
486
488
  /** Type System Extensions */
487
489
  export declare type TypeSystemExtensionNode =
488
490
  | SchemaExtensionNode
489
- | TypeExtensionNode;
491
+ | TypeExtensionNode
492
+ | DirectiveExtensionNode;
490
493
  export interface SchemaExtensionNode {
491
494
  readonly kind: Kind.SCHEMA_EXTENSION;
492
495
  readonly loc?: Location;
@@ -544,6 +547,12 @@ export interface InputObjectTypeExtensionNode {
544
547
  readonly directives?: ReadonlyArray<ConstDirectiveNode>;
545
548
  readonly fields?: ReadonlyArray<InputValueDefinitionNode>;
546
549
  }
550
+ export interface DirectiveExtensionNode {
551
+ readonly kind: Kind.DIRECTIVE_EXTENSION;
552
+ readonly loc?: Location;
553
+ readonly name: NameNode;
554
+ readonly directives?: ReadonlyArray<ConstDirectiveNode>;
555
+ }
547
556
  /** Schema Coordinates */
548
557
  export declare type SchemaCoordinateNode =
549
558
  | TypeCoordinateNode
package/language/ast.js CHANGED
@@ -200,8 +200,15 @@ const QueryDocumentKeys = {
200
200
  EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
201
201
  EnumValueDefinition: ['description', 'name', 'directives'],
202
202
  InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
203
- DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
203
+ DirectiveDefinition: [
204
+ 'description',
205
+ 'name',
206
+ 'arguments',
207
+ 'directives',
208
+ 'locations',
209
+ ],
204
210
  SchemaExtension: ['directives', 'operationTypes'],
211
+ DirectiveExtension: ['name', 'directives'],
205
212
  ScalarTypeExtension: ['name', 'directives'],
206
213
  ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
207
214
  InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
package/language/ast.mjs CHANGED
@@ -184,8 +184,15 @@ export const QueryDocumentKeys = {
184
184
  EnumTypeDefinition: ['description', 'name', 'directives', 'values'],
185
185
  EnumValueDefinition: ['description', 'name', 'directives'],
186
186
  InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'],
187
- DirectiveDefinition: ['description', 'name', 'arguments', 'locations'],
187
+ DirectiveDefinition: [
188
+ 'description',
189
+ 'name',
190
+ 'arguments',
191
+ 'directives',
192
+ 'locations',
193
+ ],
188
194
  SchemaExtension: ['directives', 'operationTypes'],
195
+ DirectiveExtension: ['name', 'directives'],
189
196
  ScalarTypeExtension: ['name', 'directives'],
190
197
  ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
191
198
  InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'],
@@ -23,6 +23,7 @@ declare enum DirectiveLocation {
23
23
  ENUM_VALUE = 'ENUM_VALUE',
24
24
  INPUT_OBJECT = 'INPUT_OBJECT',
25
25
  INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION',
26
+ DIRECTIVE_DEFINITION = 'DIRECTIVE_DEFINITION',
26
27
  }
27
28
  export { DirectiveLocation };
28
29
  /**
@@ -31,6 +31,7 @@ exports.DirectiveLocation = DirectiveLocation;
31
31
  DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE';
32
32
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
33
33
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
34
+ DirectiveLocation['DIRECTIVE_DEFINITION'] = 'DIRECTIVE_DEFINITION';
34
35
  })(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {}));
35
36
  /**
36
37
  * The enum type representing the directive location values.
@@ -23,6 +23,7 @@ var DirectiveLocation;
23
23
  DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE';
24
24
  DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT';
25
25
  DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION';
26
+ DirectiveLocation['DIRECTIVE_DEFINITION'] = 'DIRECTIVE_DEFINITION';
26
27
  })(DirectiveLocation || (DirectiveLocation = {}));
27
28
 
28
29
  export { DirectiveLocation };
@@ -86,6 +86,7 @@ export type {
86
86
  UnionTypeExtensionNode,
87
87
  EnumTypeExtensionNode,
88
88
  InputObjectTypeExtensionNode,
89
+ DirectiveExtensionNode,
89
90
  SchemaCoordinateNode,
90
91
  TypeCoordinateNode,
91
92
  MemberCoordinateNode,
@@ -49,6 +49,7 @@ declare enum Kind {
49
49
  DIRECTIVE_DEFINITION = 'DirectiveDefinition',
50
50
  /** Type System Extensions */
51
51
  SCHEMA_EXTENSION = 'SchemaExtension',
52
+ DIRECTIVE_EXTENSION = 'DirectiveExtension',
52
53
  /** Type Extensions */
53
54
  SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension',
54
55
  OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension',
package/language/kinds.js CHANGED
@@ -49,6 +49,7 @@ exports.Kind = Kind;
49
49
  Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition';
50
50
  Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition';
51
51
  Kind['SCHEMA_EXTENSION'] = 'SchemaExtension';
52
+ Kind['DIRECTIVE_EXTENSION'] = 'DirectiveExtension';
52
53
  Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension';
53
54
  Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension';
54
55
  Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension';
@@ -41,6 +41,7 @@ var Kind;
41
41
  Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition';
42
42
  Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition';
43
43
  Kind['SCHEMA_EXTENSION'] = 'SchemaExtension';
44
+ Kind['DIRECTIVE_EXTENSION'] = 'DirectiveExtension';
44
45
  Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension';
45
46
  Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension';
46
47
  Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension';
@@ -10,6 +10,7 @@ import type {
10
10
  ConstValueNode,
11
11
  DefinitionNode,
12
12
  DirectiveDefinitionNode,
13
+ DirectiveExtensionNode,
13
14
  DirectiveNode,
14
15
  DocumentNode,
15
16
  EnumTypeDefinitionNode,
@@ -89,6 +90,17 @@ export interface ParseOptions {
89
90
  * ```
90
91
  */
91
92
  allowLegacyFragmentVariables?: boolean;
93
+ /**
94
+ * EXPERIMENTAL:
95
+ *
96
+ * If enabled, the parser will parse directives on directive definitions.
97
+ * This syntax is not part of the GraphQL specification and may change.
98
+ *
99
+ * ```graphql
100
+ * directive @foo @bar on FIELD
101
+ * ```
102
+ */
103
+ experimentalDirectivesOnDirectiveDefinitions?: boolean;
92
104
  /**
93
105
  * You may override the Lexer class used to lex the source; this is used by
94
106
  * schema coordinates to introduce a lexer with a restricted syntax.
@@ -447,6 +459,7 @@ export declare class Parser {
447
459
  * - UnionTypeExtension
448
460
  * - EnumTypeExtension
449
461
  * - InputObjectTypeDefinition
462
+ * - DirectiveDefinitionExtension
450
463
  */
451
464
  parseTypeSystemExtension(): TypeSystemExtensionNode;
452
465
  /**
@@ -494,6 +507,7 @@ export declare class Parser {
494
507
  * - extend input Name Directives[Const]
495
508
  */
496
509
  parseInputObjectTypeExtension(): InputObjectTypeExtensionNode;
510
+ parseDirectiveDefinitionExtension(): DirectiveExtensionNode;
497
511
  /**
498
512
  * ```
499
513
  * DirectiveDefinition :
@@ -1112,6 +1112,7 @@ class Parser {
1112
1112
  * - UnionTypeExtension
1113
1113
  * - EnumTypeExtension
1114
1114
  * - InputObjectTypeDefinition
1115
+ * - DirectiveDefinitionExtension
1115
1116
  */
1116
1117
 
1117
1118
  parseTypeSystemExtension() {
@@ -1139,6 +1140,13 @@ class Parser {
1139
1140
 
1140
1141
  case 'input':
1141
1142
  return this.parseInputObjectTypeExtension();
1143
+
1144
+ case 'directive':
1145
+ if (this._options.experimentalDirectivesOnDirectiveDefinitions) {
1146
+ return this.parseDirectiveDefinitionExtension();
1147
+ }
1148
+
1149
+ break;
1142
1150
  }
1143
1151
  }
1144
1152
 
@@ -1334,6 +1342,25 @@ class Parser {
1334
1342
  fields,
1335
1343
  });
1336
1344
  }
1345
+
1346
+ parseDirectiveDefinitionExtension() {
1347
+ const start = this._lexer.token;
1348
+ this.expectKeyword('extend');
1349
+ this.expectKeyword('directive');
1350
+ this.expectToken(_tokenKind.TokenKind.AT);
1351
+ const name = this.parseName();
1352
+ const directives = this.parseConstDirectives();
1353
+
1354
+ if (directives.length === 0) {
1355
+ throw this.unexpected();
1356
+ }
1357
+
1358
+ return this.node(start, {
1359
+ kind: _kinds.Kind.DIRECTIVE_EXTENSION,
1360
+ name,
1361
+ directives,
1362
+ });
1363
+ }
1337
1364
  /**
1338
1365
  * ```
1339
1366
  * DirectiveDefinition :
@@ -1348,6 +1375,10 @@ class Parser {
1348
1375
  this.expectToken(_tokenKind.TokenKind.AT);
1349
1376
  const name = this.parseName();
1350
1377
  const args = this.parseArgumentDefs();
1378
+ const directives = this._options
1379
+ .experimentalDirectivesOnDirectiveDefinitions
1380
+ ? this.parseConstDirectives()
1381
+ : [];
1351
1382
  const repeatable = this.expectOptionalKeyword('repeatable');
1352
1383
  this.expectKeyword('on');
1353
1384
  const locations = this.parseDirectiveLocations();
@@ -1356,6 +1387,7 @@ class Parser {
1356
1387
  description,
1357
1388
  name,
1358
1389
  arguments: args,
1390
+ directives,
1359
1391
  repeatable,
1360
1392
  locations,
1361
1393
  });
@@ -1398,6 +1430,7 @@ class Parser {
1398
1430
  * `ENUM_VALUE`
1399
1431
  * `INPUT_OBJECT`
1400
1432
  * `INPUT_FIELD_DEFINITION`
1433
+ * `DIRECTIVE_DEFINITION`
1401
1434
  */
1402
1435
 
1403
1436
  parseDirectiveLocation() {
@@ -1075,6 +1075,7 @@ export class Parser {
1075
1075
  * - UnionTypeExtension
1076
1076
  * - EnumTypeExtension
1077
1077
  * - InputObjectTypeDefinition
1078
+ * - DirectiveDefinitionExtension
1078
1079
  */
1079
1080
 
1080
1081
  parseTypeSystemExtension() {
@@ -1102,6 +1103,13 @@ export class Parser {
1102
1103
 
1103
1104
  case 'input':
1104
1105
  return this.parseInputObjectTypeExtension();
1106
+
1107
+ case 'directive':
1108
+ if (this._options.experimentalDirectivesOnDirectiveDefinitions) {
1109
+ return this.parseDirectiveDefinitionExtension();
1110
+ }
1111
+
1112
+ break;
1105
1113
  }
1106
1114
  }
1107
1115
 
@@ -1297,6 +1305,25 @@ export class Parser {
1297
1305
  fields,
1298
1306
  });
1299
1307
  }
1308
+
1309
+ parseDirectiveDefinitionExtension() {
1310
+ const start = this._lexer.token;
1311
+ this.expectKeyword('extend');
1312
+ this.expectKeyword('directive');
1313
+ this.expectToken(TokenKind.AT);
1314
+ const name = this.parseName();
1315
+ const directives = this.parseConstDirectives();
1316
+
1317
+ if (directives.length === 0) {
1318
+ throw this.unexpected();
1319
+ }
1320
+
1321
+ return this.node(start, {
1322
+ kind: Kind.DIRECTIVE_EXTENSION,
1323
+ name,
1324
+ directives,
1325
+ });
1326
+ }
1300
1327
  /**
1301
1328
  * ```
1302
1329
  * DirectiveDefinition :
@@ -1311,6 +1338,10 @@ export class Parser {
1311
1338
  this.expectToken(TokenKind.AT);
1312
1339
  const name = this.parseName();
1313
1340
  const args = this.parseArgumentDefs();
1341
+ const directives = this._options
1342
+ .experimentalDirectivesOnDirectiveDefinitions
1343
+ ? this.parseConstDirectives()
1344
+ : [];
1314
1345
  const repeatable = this.expectOptionalKeyword('repeatable');
1315
1346
  this.expectKeyword('on');
1316
1347
  const locations = this.parseDirectiveLocations();
@@ -1319,6 +1350,7 @@ export class Parser {
1319
1350
  description,
1320
1351
  name,
1321
1352
  arguments: args,
1353
+ directives,
1322
1354
  repeatable,
1323
1355
  locations,
1324
1356
  });
@@ -1358,6 +1390,7 @@ export class Parser {
1358
1390
  * `ENUM_VALUE`
1359
1391
  * `INPUT_OBJECT`
1360
1392
  * `INPUT_FIELD_DEFINITION`
1393
+ * `DIRECTIVE_DEFINITION`
1361
1394
  */
1362
1395
 
1363
1396
  parseDirectiveLocation() {
@@ -94,7 +94,9 @@ function isTypeDefinitionNode(node) {
94
94
 
95
95
  function isTypeSystemExtensionNode(node) {
96
96
  return (
97
- node.kind === _kinds.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node)
97
+ node.kind === _kinds.Kind.SCHEMA_EXTENSION ||
98
+ node.kind === _kinds.Kind.DIRECTIVE_EXTENSION ||
99
+ isTypeExtensionNode(node)
98
100
  );
99
101
  }
100
102
 
@@ -67,7 +67,11 @@ export function isTypeDefinitionNode(node) {
67
67
  );
68
68
  }
69
69
  export function isTypeSystemExtensionNode(node) {
70
- return node.kind === Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node);
70
+ return (
71
+ node.kind === Kind.SCHEMA_EXTENSION ||
72
+ node.kind === Kind.DIRECTIVE_EXTENSION ||
73
+ isTypeExtensionNode(node)
74
+ );
71
75
  }
72
76
  export function isTypeExtensionNode(node) {
73
77
  return (
@@ -240,13 +240,21 @@ const printDocASTReducer = {
240
240
  join(['input', name, join(directives, ' '), block(fields)], ' '),
241
241
  },
242
242
  DirectiveDefinition: {
243
- leave: ({ description, name, arguments: args, repeatable, locations }) =>
243
+ leave: ({
244
+ description,
245
+ name,
246
+ arguments: args,
247
+ directives,
248
+ repeatable,
249
+ locations,
250
+ }) =>
244
251
  wrap('', description, '\n') +
245
252
  'directive @' +
246
253
  name +
247
254
  (hasMultilineItems(args)
248
255
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
249
256
  : wrap('(', join(args, ', '), ')')) +
257
+ wrap(' ', join(directives, ' ')) +
250
258
  (repeatable ? ' repeatable' : '') +
251
259
  ' on ' +
252
260
  join(locations, ' | '),
@@ -308,6 +316,10 @@ const printDocASTReducer = {
308
316
  leave: ({ name, directives, fields }) =>
309
317
  join(['extend input', name, join(directives, ' '), block(fields)], ' '),
310
318
  },
319
+ DirectiveExtension: {
320
+ leave: ({ name, directives }) =>
321
+ join(['extend directive @' + name, join(directives, ' ')], ' '),
322
+ },
311
323
  // Schema Coordinates
312
324
  TypeCoordinate: {
313
325
  leave: ({ name }) => name,
@@ -228,13 +228,21 @@ const printDocASTReducer = {
228
228
  join(['input', name, join(directives, ' '), block(fields)], ' '),
229
229
  },
230
230
  DirectiveDefinition: {
231
- leave: ({ description, name, arguments: args, repeatable, locations }) =>
231
+ leave: ({
232
+ description,
233
+ name,
234
+ arguments: args,
235
+ directives,
236
+ repeatable,
237
+ locations,
238
+ }) =>
232
239
  wrap('', description, '\n') +
233
240
  'directive @' +
234
241
  name +
235
242
  (hasMultilineItems(args)
236
243
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
237
244
  : wrap('(', join(args, ', '), ')')) +
245
+ wrap(' ', join(directives, ' ')) +
238
246
  (repeatable ? ' repeatable' : '') +
239
247
  ' on ' +
240
248
  join(locations, ' | '),
@@ -296,6 +304,10 @@ const printDocASTReducer = {
296
304
  leave: ({ name, directives, fields }) =>
297
305
  join(['extend input', name, join(directives, ' '), block(fields)], ' '),
298
306
  },
307
+ DirectiveExtension: {
308
+ leave: ({ name, directives }) =>
309
+ join(['extend directive @' + name, join(directives, ' ')], ' '),
310
+ },
299
311
  // Schema Coordinates
300
312
  TypeCoordinate: {
301
313
  leave: ({ name }) => name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql",
3
- "version": "16.13.2",
3
+ "version": "16.14.0",
4
4
  "description": "A Query Language and Runtime which can target any service.",
5
5
  "license": "MIT",
6
6
  "main": "index",
@@ -1,5 +1,8 @@
1
1
  import type { Maybe } from '../jsutils/Maybe';
2
- import type { DirectiveDefinitionNode } from '../language/ast';
2
+ import type {
3
+ DirectiveDefinitionNode,
4
+ DirectiveExtensionNode,
5
+ } from '../language/ast';
3
6
  import { DirectiveLocation } from '../language/directiveLocation';
4
7
  import type {
5
8
  GraphQLArgument,
@@ -34,8 +37,10 @@ export declare class GraphQLDirective {
34
37
  locations: ReadonlyArray<DirectiveLocation>;
35
38
  args: ReadonlyArray<GraphQLArgument>;
36
39
  isRepeatable: boolean;
40
+ deprecationReason: Maybe<string>;
37
41
  extensions: Readonly<GraphQLDirectiveExtensions>;
38
42
  astNode: Maybe<DirectiveDefinitionNode>;
43
+ extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;
39
44
  constructor(config: Readonly<GraphQLDirectiveConfig>);
40
45
  get [Symbol.toStringTag](): string;
41
46
  toConfig(): GraphQLDirectiveNormalizedConfig;
@@ -48,13 +53,16 @@ export interface GraphQLDirectiveConfig {
48
53
  locations: ReadonlyArray<DirectiveLocation>;
49
54
  args?: Maybe<GraphQLFieldConfigArgumentMap>;
50
55
  isRepeatable?: Maybe<boolean>;
56
+ deprecationReason?: Maybe<string>;
51
57
  extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
52
58
  astNode?: Maybe<DirectiveDefinitionNode>;
59
+ extensionASTNodes?: Maybe<ReadonlyArray<DirectiveExtensionNode>>;
53
60
  }
54
61
  interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {
55
62
  args: GraphQLFieldConfigArgumentMap;
56
63
  isRepeatable: boolean;
57
64
  extensions: Readonly<GraphQLDirectiveExtensions>;
65
+ extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;
58
66
  }
59
67
  /**
60
68
  * Used to conditionally include fields or fragments.
@@ -66,7 +66,7 @@ function assertDirective(directive) {
66
66
  */
67
67
  class GraphQLDirective {
68
68
  constructor(config) {
69
- var _config$isRepeatable, _config$args;
69
+ var _config$isRepeatable, _config$extensionASTN, _config$args;
70
70
 
71
71
  this.name = (0, _assertName.assertName)(config.name);
72
72
  this.description = config.description;
@@ -76,8 +76,14 @@ class GraphQLDirective {
76
76
  _config$isRepeatable !== void 0
77
77
  ? _config$isRepeatable
78
78
  : false;
79
+ this.deprecationReason = config.deprecationReason;
79
80
  this.extensions = (0, _toObjMap.toObjMap)(config.extensions);
80
81
  this.astNode = config.astNode;
82
+ this.extensionASTNodes =
83
+ (_config$extensionASTN = config.extensionASTNodes) !== null &&
84
+ _config$extensionASTN !== void 0
85
+ ? _config$extensionASTN
86
+ : [];
81
87
  Array.isArray(config.locations) ||
82
88
  (0, _devAssert.devAssert)(
83
89
  false,
@@ -106,8 +112,10 @@ class GraphQLDirective {
106
112
  locations: this.locations,
107
113
  args: (0, _definition.argsToArgsConfig)(this.args),
108
114
  isRepeatable: this.isRepeatable,
115
+ deprecationReason: this.deprecationReason,
109
116
  extensions: this.extensions,
110
117
  astNode: this.astNode,
118
+ extensionASTNodes: this.extensionASTNodes,
111
119
  };
112
120
  }
113
121
 
@@ -181,6 +189,7 @@ const GraphQLDeprecatedDirective = new GraphQLDirective({
181
189
  _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION,
182
190
  _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION,
183
191
  _directiveLocation.DirectiveLocation.ENUM_VALUE,
192
+ _directiveLocation.DirectiveLocation.DIRECTIVE_DEFINITION,
184
193
  ],
185
194
  args: {
186
195
  reason: {
@@ -43,7 +43,7 @@ export function assertDirective(directive) {
43
43
  */
44
44
  export class GraphQLDirective {
45
45
  constructor(config) {
46
- var _config$isRepeatable, _config$args;
46
+ var _config$isRepeatable, _config$extensionASTN, _config$args;
47
47
 
48
48
  this.name = assertName(config.name);
49
49
  this.description = config.description;
@@ -53,8 +53,14 @@ export class GraphQLDirective {
53
53
  _config$isRepeatable !== void 0
54
54
  ? _config$isRepeatable
55
55
  : false;
56
+ this.deprecationReason = config.deprecationReason;
56
57
  this.extensions = toObjMap(config.extensions);
57
58
  this.astNode = config.astNode;
59
+ this.extensionASTNodes =
60
+ (_config$extensionASTN = config.extensionASTNodes) !== null &&
61
+ _config$extensionASTN !== void 0
62
+ ? _config$extensionASTN
63
+ : [];
58
64
  Array.isArray(config.locations) ||
59
65
  devAssert(false, `@${config.name} locations must be an Array.`);
60
66
  const args =
@@ -80,8 +86,10 @@ export class GraphQLDirective {
80
86
  locations: this.locations,
81
87
  args: argsToArgsConfig(this.args),
82
88
  isRepeatable: this.isRepeatable,
89
+ deprecationReason: this.deprecationReason,
83
90
  extensions: this.extensions,
84
91
  astNode: this.astNode,
92
+ extensionASTNodes: this.extensionASTNodes,
85
93
  };
86
94
  }
87
95
 
@@ -150,6 +158,7 @@ export const GraphQLDeprecatedDirective = new GraphQLDirective({
150
158
  DirectiveLocation.ARGUMENT_DEFINITION,
151
159
  DirectiveLocation.INPUT_FIELD_DEFINITION,
152
160
  DirectiveLocation.ENUM_VALUE,
161
+ DirectiveLocation.DIRECTIVE_DEFINITION,
153
162
  ],
154
163
  args: {
155
164
  reason: {
@@ -76,7 +76,18 @@ const __Schema = new _definition.GraphQLObjectType({
76
76
  new _definition.GraphQLNonNull(__Directive),
77
77
  ),
78
78
  ),
79
- resolve: (schema) => schema.getDirectives(),
79
+ args: {
80
+ includeDeprecated: {
81
+ type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
82
+ defaultValue: false,
83
+ },
84
+ },
85
+ resolve: (schema, { includeDeprecated }) =>
86
+ includeDeprecated
87
+ ? schema.getDirectives()
88
+ : schema
89
+ .getDirectives()
90
+ .filter((directive) => directive.deprecationReason == null),
80
91
  },
81
92
  }),
82
93
  });
@@ -127,6 +138,14 @@ const __Directive = new _definition.GraphQLObjectType({
127
138
  : field.args.filter((arg) => arg.deprecationReason == null);
128
139
  },
129
140
  },
141
+ isDeprecated: {
142
+ type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
143
+ resolve: (directive) => directive.deprecationReason != null,
144
+ },
145
+ deprecationReason: {
146
+ type: _scalars.GraphQLString,
147
+ resolve: (directive) => directive.deprecationReason,
148
+ },
130
149
  }),
131
150
  });
132
151
 
@@ -213,6 +232,10 @@ const __DirectiveLocation = new _definition.GraphQLEnumType({
213
232
  value: _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION,
214
233
  description: 'Location adjacent to an input object field definition.',
215
234
  },
235
+ DIRECTIVE_DEFINITION: {
236
+ value: _directiveLocation.DirectiveLocation.DIRECTIVE_DEFINITION,
237
+ description: 'Location adjacent to a directive definition.',
238
+ },
216
239
  },
217
240
  });
218
241
 
@@ -58,7 +58,18 @@ export const __Schema = new GraphQLObjectType({
58
58
  type: new GraphQLNonNull(
59
59
  new GraphQLList(new GraphQLNonNull(__Directive)),
60
60
  ),
61
- resolve: (schema) => schema.getDirectives(),
61
+ args: {
62
+ includeDeprecated: {
63
+ type: new GraphQLNonNull(GraphQLBoolean),
64
+ defaultValue: false,
65
+ },
66
+ },
67
+ resolve: (schema, { includeDeprecated }) =>
68
+ includeDeprecated
69
+ ? schema.getDirectives()
70
+ : schema
71
+ .getDirectives()
72
+ .filter((directive) => directive.deprecationReason == null),
62
73
  },
63
74
  }),
64
75
  });
@@ -102,6 +113,14 @@ export const __Directive = new GraphQLObjectType({
102
113
  : field.args.filter((arg) => arg.deprecationReason == null);
103
114
  },
104
115
  },
116
+ isDeprecated: {
117
+ type: new GraphQLNonNull(GraphQLBoolean),
118
+ resolve: (directive) => directive.deprecationReason != null,
119
+ },
120
+ deprecationReason: {
121
+ type: GraphQLString,
122
+ resolve: (directive) => directive.deprecationReason,
123
+ },
105
124
  }),
106
125
  });
107
126
  export const __DirectiveLocation = new GraphQLEnumType({
@@ -185,6 +204,10 @@ export const __DirectiveLocation = new GraphQLEnumType({
185
204
  value: DirectiveLocation.INPUT_FIELD_DEFINITION,
186
205
  description: 'Location adjacent to an input object field definition.',
187
206
  },
207
+ DIRECTIVE_DEFINITION: {
208
+ value: DirectiveLocation.DIRECTIVE_DEFINITION,
209
+ description: 'Location adjacent to a directive definition.',
210
+ },
188
211
  },
189
212
  });
190
213
  export const __Type = new GraphQLObjectType({
@@ -105,6 +105,10 @@ function buildSchema(source, options) {
105
105
  options === null || options === void 0
106
106
  ? void 0
107
107
  : options.allowLegacyFragmentVariables,
108
+ experimentalDirectivesOnDirectiveDefinitions:
109
+ options === null || options === void 0
110
+ ? void 0
111
+ : options.experimentalDirectivesOnDirectiveDefinitions,
108
112
  });
109
113
  return buildASTSchema(document, {
110
114
  assumeValidSDL: