graphql 15.0.0 → 15.1.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 (164) hide show
  1. package/README.md +5 -5
  2. package/error/GraphQLError.d.ts +2 -2
  3. package/error/GraphQLError.js +4 -5
  4. package/error/GraphQLError.js.flow +1 -1
  5. package/error/GraphQLError.mjs +4 -5
  6. package/error/locatedError.d.ts +1 -1
  7. package/execution/execute.d.ts +8 -6
  8. package/execution/execute.js +4 -6
  9. package/execution/execute.js.flow +3 -2
  10. package/execution/execute.mjs +4 -6
  11. package/execution/values.d.ts +2 -1
  12. package/execution/values.js +1 -2
  13. package/execution/values.js.flow +1 -1
  14. package/execution/values.mjs +1 -2
  15. package/graphql.d.ts +2 -1
  16. package/index.d.ts +3 -2
  17. package/index.js +18 -0
  18. package/index.js.flow +3 -2
  19. package/index.mjs +2 -2
  20. package/jsutils/Maybe.d.ts +2 -0
  21. package/jsutils/Path.d.ts +2 -2
  22. package/jsutils/defineInspect.js +25 -0
  23. package/jsutils/defineInspect.js.flow +21 -0
  24. package/jsutils/defineInspect.mjs +15 -0
  25. package/jsutils/devAssert.js +1 -2
  26. package/jsutils/devAssert.js.flow +1 -1
  27. package/jsutils/devAssert.mjs +1 -2
  28. package/jsutils/instanceOf.js +1 -2
  29. package/jsutils/instanceOf.js.flow +1 -1
  30. package/jsutils/instanceOf.mjs +1 -2
  31. package/jsutils/invariant.js +1 -2
  32. package/jsutils/invariant.js.flow +1 -1
  33. package/jsutils/invariant.mjs +1 -2
  34. package/jsutils/nodejsCustomInspectSymbol.js +1 -2
  35. package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
  36. package/jsutils/nodejsCustomInspectSymbol.mjs +1 -1
  37. package/language/ast.d.ts +11 -2
  38. package/language/ast.js +94 -80
  39. package/language/ast.js.flow +23 -14
  40. package/language/ast.mjs +86 -72
  41. package/language/blockString.js +2 -1
  42. package/language/blockString.js.flow +5 -1
  43. package/language/blockString.mjs +2 -1
  44. package/language/directiveLocation.d.ts +2 -7
  45. package/language/index.js +14 -0
  46. package/language/index.js.flow +1 -2
  47. package/language/index.mjs +1 -0
  48. package/language/kinds.d.ts +2 -7
  49. package/language/lexer.d.ts +6 -0
  50. package/language/tokenKind.d.ts +2 -4
  51. package/language/visitor.d.ts +4 -3
  52. package/package.json +2 -2
  53. package/polyfills/arrayFrom.js +1 -2
  54. package/polyfills/arrayFrom.js.flow +1 -1
  55. package/polyfills/arrayFrom.mjs +1 -2
  56. package/polyfills/symbols.js +3 -6
  57. package/polyfills/symbols.js.flow +3 -3
  58. package/polyfills/symbols.mjs +3 -6
  59. package/subscription/subscribe.d.ts +2 -1
  60. package/type/definition.d.ts +30 -21
  61. package/type/definition.js +60 -17
  62. package/type/definition.js.flow +61 -9
  63. package/type/definition.mjs +60 -17
  64. package/type/directives.d.ts +6 -1
  65. package/type/directives.js +28 -7
  66. package/type/directives.js.flow +23 -2
  67. package/type/directives.mjs +24 -4
  68. package/type/index.d.ts +1 -0
  69. package/type/index.js +6 -0
  70. package/type/index.js.flow +1 -0
  71. package/type/index.mjs +1 -1
  72. package/type/introspection.js +11 -6
  73. package/type/introspection.js.flow +8 -2
  74. package/type/introspection.mjs +11 -6
  75. package/type/schema.d.ts +7 -5
  76. package/type/validate.js +22 -8
  77. package/type/validate.js.flow +23 -11
  78. package/type/validate.mjs +22 -8
  79. package/utilities/TypeInfo.d.ts +2 -1
  80. package/utilities/astFromValue.d.ts +2 -1
  81. package/utilities/astFromValue.js +4 -5
  82. package/utilities/astFromValue.js.flow +2 -1
  83. package/utilities/astFromValue.mjs +4 -5
  84. package/utilities/buildASTSchema.js +15 -4
  85. package/utilities/buildASTSchema.js.flow +13 -2
  86. package/utilities/buildASTSchema.mjs +15 -4
  87. package/utilities/buildClientSchema.js +2 -1
  88. package/utilities/buildClientSchema.js.flow +1 -0
  89. package/utilities/buildClientSchema.mjs +2 -1
  90. package/utilities/coerceInputValue.js +4 -5
  91. package/utilities/coerceInputValue.js.flow +2 -1
  92. package/utilities/coerceInputValue.mjs +4 -5
  93. package/utilities/extendSchema.d.ts +2 -1
  94. package/utilities/extendSchema.js +78 -66
  95. package/utilities/extendSchema.js.flow +30 -9
  96. package/utilities/extendSchema.mjs +79 -67
  97. package/utilities/findBreakingChanges.d.ts +6 -16
  98. package/utilities/findBreakingChanges.js +5 -8
  99. package/utilities/findBreakingChanges.js.flow +2 -1
  100. package/utilities/findBreakingChanges.mjs +5 -8
  101. package/utilities/getIntrospectionQuery.d.ts +12 -2
  102. package/utilities/getIntrospectionQuery.js +3 -1
  103. package/utilities/getIntrospectionQuery.js.flow +10 -0
  104. package/utilities/getIntrospectionQuery.mjs +3 -1
  105. package/utilities/getOperationAST.d.ts +3 -2
  106. package/utilities/getOperationAST.js.flow +1 -1
  107. package/utilities/introspectionFromSchema.js +0 -2
  108. package/utilities/introspectionFromSchema.mjs +0 -2
  109. package/utilities/lexicographicSortSchema.js +14 -15
  110. package/utilities/lexicographicSortSchema.js.flow +2 -1
  111. package/utilities/lexicographicSortSchema.mjs +14 -15
  112. package/utilities/printSchema.js +16 -6
  113. package/utilities/printSchema.js.flow +20 -2
  114. package/utilities/printSchema.mjs +16 -6
  115. package/utilities/typeFromAST.js +4 -5
  116. package/utilities/typeFromAST.js.flow +2 -1
  117. package/utilities/typeFromAST.mjs +4 -5
  118. package/utilities/valueFromAST.d.ts +2 -1
  119. package/utilities/valueFromAST.js +4 -5
  120. package/utilities/valueFromAST.js.flow +2 -1
  121. package/utilities/valueFromAST.mjs +4 -5
  122. package/utilities/valueFromASTUntyped.d.ts +2 -1
  123. package/utilities/valueFromASTUntyped.js +2 -3
  124. package/utilities/valueFromASTUntyped.js.flow +1 -1
  125. package/utilities/valueFromASTUntyped.mjs +2 -3
  126. package/validation/ValidationContext.d.ts +4 -3
  127. package/validation/ValidationContext.js +0 -16
  128. package/validation/ValidationContext.mjs +0 -16
  129. package/validation/rules/KnownArgumentNamesRule.js +2 -2
  130. package/validation/rules/KnownArgumentNamesRule.js.flow +1 -1
  131. package/validation/rules/KnownArgumentNamesRule.mjs +2 -2
  132. package/validation/rules/KnownDirectivesRule.js +2 -5
  133. package/validation/rules/KnownDirectivesRule.js.flow +1 -1
  134. package/validation/rules/KnownDirectivesRule.mjs +2 -5
  135. package/validation/rules/KnownTypeNamesRule.d.ts +4 -2
  136. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +2 -4
  137. package/validation/rules/OverlappingFieldsCanBeMergedRule.js.flow +2 -2
  138. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +2 -4
  139. package/validation/rules/PossibleTypeExtensionsRule.js +6 -8
  140. package/validation/rules/PossibleTypeExtensionsRule.js.flow +3 -2
  141. package/validation/rules/PossibleTypeExtensionsRule.mjs +6 -8
  142. package/validation/rules/ProvidedRequiredArgumentsRule.js +4 -5
  143. package/validation/rules/ProvidedRequiredArgumentsRule.js.flow +3 -3
  144. package/validation/rules/ProvidedRequiredArgumentsRule.mjs +4 -5
  145. package/validation/rules/UniqueEnumValueNamesRule.js +1 -2
  146. package/validation/rules/UniqueEnumValueNamesRule.js.flow +1 -1
  147. package/validation/rules/UniqueEnumValueNamesRule.mjs +1 -2
  148. package/validation/rules/UniqueFieldDefinitionNamesRule.js +1 -2
  149. package/validation/rules/UniqueFieldDefinitionNamesRule.js.flow +1 -1
  150. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +1 -2
  151. package/validation/rules/UniqueOperationTypesRule.js +1 -1
  152. package/validation/rules/UniqueOperationTypesRule.js.flow +1 -1
  153. package/validation/rules/UniqueOperationTypesRule.mjs +1 -1
  154. package/validation/validate.d.ts +3 -3
  155. package/version.js +3 -3
  156. package/version.js.flow +3 -3
  157. package/version.mjs +3 -3
  158. package/jsutils/dedent.js +0 -50
  159. package/jsutils/dedent.js.flow +0 -44
  160. package/jsutils/dedent.mjs +0 -43
  161. package/jsutils/defineToJSON.js +0 -25
  162. package/jsutils/defineToJSON.js.flow +0 -20
  163. package/jsutils/defineToJSON.mjs +0 -16
  164. package/tsutils/Maybe.d.ts +0 -6
package/type/validate.js CHANGED
@@ -106,23 +106,29 @@ function validateRootTypes(context) {
106
106
  if (!queryType) {
107
107
  context.reportError('Query root type must be provided.', schema.astNode);
108
108
  } else if (!(0, _definition.isObjectType)(queryType)) {
109
- context.reportError("Query root type must be Object type, it cannot be ".concat((0, _inspect.default)(queryType), "."), getOperationTypeNode(schema, queryType, 'query'));
109
+ var _getOperationTypeNode;
110
+
111
+ context.reportError("Query root type must be Object type, it cannot be ".concat((0, _inspect.default)(queryType), "."), (_getOperationTypeNode = getOperationTypeNode(schema, 'query')) !== null && _getOperationTypeNode !== void 0 ? _getOperationTypeNode : queryType.astNode);
110
112
  }
111
113
 
112
114
  var mutationType = schema.getMutationType();
113
115
 
114
116
  if (mutationType && !(0, _definition.isObjectType)(mutationType)) {
115
- context.reportError('Mutation root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(mutationType), "."), getOperationTypeNode(schema, mutationType, 'mutation'));
117
+ var _getOperationTypeNode2;
118
+
119
+ context.reportError('Mutation root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(mutationType), "."), (_getOperationTypeNode2 = getOperationTypeNode(schema, 'mutation')) !== null && _getOperationTypeNode2 !== void 0 ? _getOperationTypeNode2 : mutationType.astNode);
116
120
  }
117
121
 
118
122
  var subscriptionType = schema.getSubscriptionType();
119
123
 
120
124
  if (subscriptionType && !(0, _definition.isObjectType)(subscriptionType)) {
121
- context.reportError('Subscription root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(subscriptionType), "."), getOperationTypeNode(schema, subscriptionType, 'subscription'));
125
+ var _getOperationTypeNode3;
126
+
127
+ context.reportError('Subscription root type must be Object type if provided, it cannot be ' + "".concat((0, _inspect.default)(subscriptionType), "."), (_getOperationTypeNode3 = getOperationTypeNode(schema, 'subscription')) !== null && _getOperationTypeNode3 !== void 0 ? _getOperationTypeNode3 : subscriptionType.astNode);
122
128
  }
123
129
  }
124
130
 
125
- function getOperationTypeNode(schema, type, operation) {
131
+ function getOperationTypeNode(schema, operation) {
126
132
  var operationNodes = getAllSubNodes(schema, function (node) {
127
133
  return node.operationTypes;
128
134
  });
@@ -135,7 +141,7 @@ function getOperationTypeNode(schema, type, operation) {
135
141
  }
136
142
  }
137
143
 
138
- return type.astNode;
144
+ return undefined;
139
145
  }
140
146
 
141
147
  function validateDirectives(context) {
@@ -293,7 +299,11 @@ function validateTypeImplementsInterface(context, type, iface) {
293
299
 
294
300
 
295
301
  if (!(0, _typeComparators.isTypeSubTypeOf)(context.schema, typeField.type, ifaceField.type)) {
296
- context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expects type ") + "".concat((0, _inspect.default)(ifaceField.type), " but ").concat(type.name, ".").concat(fieldName, " ") + "is type ".concat((0, _inspect.default)(typeField.type), "."), [ifaceField.astNode.type, typeField.astNode.type]);
302
+ var _ifaceField$astNode, _typeField$astNode;
303
+
304
+ context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expects type ") + "".concat((0, _inspect.default)(ifaceField.type), " but ").concat(type.name, ".").concat(fieldName, " ") + "is type ".concat((0, _inspect.default)(typeField.type), "."), [// istanbul ignore next (TODO need to write coverage tests)
305
+ (_ifaceField$astNode = ifaceField.astNode) === null || _ifaceField$astNode === void 0 ? void 0 : _ifaceField$astNode.type, // istanbul ignore next (TODO need to write coverage tests)
306
+ (_typeField$astNode = typeField.astNode) === null || _typeField$astNode === void 0 ? void 0 : _typeField$astNode.type]);
297
307
  } // Assert each interface field arg is implemented.
298
308
 
299
309
 
@@ -313,7 +323,11 @@ function validateTypeImplementsInterface(context, type, iface) {
313
323
 
314
324
 
315
325
  if (!(0, _typeComparators.isEqualType)(ifaceArg.type, typeArg.type)) {
316
- context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expects type ".concat((0, _inspect.default)(ifaceArg.type), " but ") + "".concat(type.name, ".").concat(fieldName, "(").concat(argName, ":) is type ") + "".concat((0, _inspect.default)(typeArg.type), "."), [ifaceArg.astNode.type, typeArg.astNode.type]);
326
+ var _ifaceArg$astNode, _typeArg$astNode;
327
+
328
+ context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expects type ".concat((0, _inspect.default)(ifaceArg.type), " but ") + "".concat(type.name, ".").concat(fieldName, "(").concat(argName, ":) is type ") + "".concat((0, _inspect.default)(typeArg.type), "."), [// istanbul ignore next (TODO need to write coverage tests)
329
+ (_ifaceArg$astNode = ifaceArg.astNode) === null || _ifaceArg$astNode === void 0 ? void 0 : _ifaceArg$astNode.type, // istanbul ignore next (TODO need to write coverage tests)
330
+ (_typeArg$astNode = typeArg.astNode) === null || _typeArg$astNode === void 0 ? void 0 : _typeArg$astNode.type]);
317
331
  } // TODO: validate default values?
318
332
 
319
333
  };
@@ -477,7 +491,7 @@ function getAllNodes(object) {
477
491
  }
478
492
 
479
493
  function getAllSubNodes(object, getter) {
480
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
494
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
481
495
  return (0, _flatMap.default)(getAllNodes(object), function (item) {
482
496
  var _getter;
483
497
 
@@ -9,7 +9,11 @@ import inspect from '../jsutils/inspect';
9
9
  import { GraphQLError } from '../error/GraphQLError';
10
10
  import { locatedError } from '../error/locatedError';
11
11
 
12
- import { type ASTNode, type NamedTypeNode } from '../language/ast';
12
+ import {
13
+ type ASTNode,
14
+ type NamedTypeNode,
15
+ type OperationTypeNode,
16
+ } from '../language/ast';
13
17
 
14
18
  import { isValidNameError } from '../utilities/assertValidName';
15
19
  import { isEqualType, isTypeSubTypeOf } from '../utilities/typeComparators';
@@ -113,7 +117,7 @@ function validateRootTypes(context) {
113
117
  `Query root type must be Object type, it cannot be ${inspect(
114
118
  queryType,
115
119
  )}.`,
116
- getOperationTypeNode(schema, queryType, 'query'),
120
+ getOperationTypeNode(schema, 'query') ?? queryType.astNode,
117
121
  );
118
122
  }
119
123
 
@@ -122,7 +126,7 @@ function validateRootTypes(context) {
122
126
  context.reportError(
123
127
  'Mutation root type must be Object type if provided, it cannot be ' +
124
128
  `${inspect(mutationType)}.`,
125
- getOperationTypeNode(schema, mutationType, 'mutation'),
129
+ getOperationTypeNode(schema, 'mutation') ?? mutationType.astNode,
126
130
  );
127
131
  }
128
132
 
@@ -131,15 +135,14 @@ function validateRootTypes(context) {
131
135
  context.reportError(
132
136
  'Subscription root type must be Object type if provided, it cannot be ' +
133
137
  `${inspect(subscriptionType)}.`,
134
- getOperationTypeNode(schema, subscriptionType, 'subscription'),
138
+ getOperationTypeNode(schema, 'subscription') ?? subscriptionType.astNode,
135
139
  );
136
140
  }
137
141
  }
138
142
 
139
143
  function getOperationTypeNode(
140
144
  schema: GraphQLSchema,
141
- type: GraphQLObjectType,
142
- operation: string,
145
+ operation: OperationTypeNode,
143
146
  ): ?ASTNode {
144
147
  const operationNodes = getAllSubNodes(schema, (node) => node.operationTypes);
145
148
  for (const node of operationNodes) {
@@ -147,8 +150,7 @@ function getOperationTypeNode(
147
150
  return node.type;
148
151
  }
149
152
  }
150
-
151
- return type.astNode;
153
+ return undefined;
152
154
  }
153
155
 
154
156
  function validateDirectives(context: SchemaValidationContext): void {
@@ -355,7 +357,12 @@ function validateTypeImplementsInterface(
355
357
  `Interface field ${iface.name}.${fieldName} expects type ` +
356
358
  `${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` +
357
359
  `is type ${inspect(typeField.type)}.`,
358
- [ifaceField.astNode.type, typeField.astNode.type],
360
+ [
361
+ // istanbul ignore next (TODO need to write coverage tests)
362
+ ifaceField.astNode?.type,
363
+ // istanbul ignore next (TODO need to write coverage tests)
364
+ typeField.astNode?.type,
365
+ ],
359
366
  );
360
367
  }
361
368
 
@@ -382,7 +389,12 @@ function validateTypeImplementsInterface(
382
389
  `expects type ${inspect(ifaceArg.type)} but ` +
383
390
  `${type.name}.${fieldName}(${argName}:) is type ` +
384
391
  `${inspect(typeArg.type)}.`,
385
- [ifaceArg.astNode.type, typeArg.astNode.type],
392
+ [
393
+ // istanbul ignore next (TODO need to write coverage tests)
394
+ ifaceArg.astNode?.type,
395
+ // istanbul ignore next (TODO need to write coverage tests)
396
+ typeArg.astNode?.type,
397
+ ],
386
398
  );
387
399
  }
388
400
 
@@ -586,7 +598,7 @@ function getAllSubNodes<T: ASTNode, K: ASTNode, L: ASTNode>(
586
598
  object: SDLDefinedObject<T, K>,
587
599
  getter: (T | K) => ?(L | $ReadOnlyArray<L>),
588
600
  ): $ReadOnlyArray<L> {
589
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
601
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
590
602
  return flatMap(getAllNodes(object), (item) => getter(item) ?? []);
591
603
  }
592
604
 
package/type/validate.mjs CHANGED
@@ -84,23 +84,29 @@ function validateRootTypes(context) {
84
84
  if (!queryType) {
85
85
  context.reportError('Query root type must be provided.', schema.astNode);
86
86
  } else if (!isObjectType(queryType)) {
87
- context.reportError("Query root type must be Object type, it cannot be ".concat(inspect(queryType), "."), getOperationTypeNode(schema, queryType, 'query'));
87
+ var _getOperationTypeNode;
88
+
89
+ context.reportError("Query root type must be Object type, it cannot be ".concat(inspect(queryType), "."), (_getOperationTypeNode = getOperationTypeNode(schema, 'query')) !== null && _getOperationTypeNode !== void 0 ? _getOperationTypeNode : queryType.astNode);
88
90
  }
89
91
 
90
92
  var mutationType = schema.getMutationType();
91
93
 
92
94
  if (mutationType && !isObjectType(mutationType)) {
93
- context.reportError('Mutation root type must be Object type if provided, it cannot be ' + "".concat(inspect(mutationType), "."), getOperationTypeNode(schema, mutationType, 'mutation'));
95
+ var _getOperationTypeNode2;
96
+
97
+ context.reportError('Mutation root type must be Object type if provided, it cannot be ' + "".concat(inspect(mutationType), "."), (_getOperationTypeNode2 = getOperationTypeNode(schema, 'mutation')) !== null && _getOperationTypeNode2 !== void 0 ? _getOperationTypeNode2 : mutationType.astNode);
94
98
  }
95
99
 
96
100
  var subscriptionType = schema.getSubscriptionType();
97
101
 
98
102
  if (subscriptionType && !isObjectType(subscriptionType)) {
99
- context.reportError('Subscription root type must be Object type if provided, it cannot be ' + "".concat(inspect(subscriptionType), "."), getOperationTypeNode(schema, subscriptionType, 'subscription'));
103
+ var _getOperationTypeNode3;
104
+
105
+ context.reportError('Subscription root type must be Object type if provided, it cannot be ' + "".concat(inspect(subscriptionType), "."), (_getOperationTypeNode3 = getOperationTypeNode(schema, 'subscription')) !== null && _getOperationTypeNode3 !== void 0 ? _getOperationTypeNode3 : subscriptionType.astNode);
100
106
  }
101
107
  }
102
108
 
103
- function getOperationTypeNode(schema, type, operation) {
109
+ function getOperationTypeNode(schema, operation) {
104
110
  var operationNodes = getAllSubNodes(schema, function (node) {
105
111
  return node.operationTypes;
106
112
  });
@@ -113,7 +119,7 @@ function getOperationTypeNode(schema, type, operation) {
113
119
  }
114
120
  }
115
121
 
116
- return type.astNode;
122
+ return undefined;
117
123
  }
118
124
 
119
125
  function validateDirectives(context) {
@@ -271,7 +277,11 @@ function validateTypeImplementsInterface(context, type, iface) {
271
277
 
272
278
 
273
279
  if (!isTypeSubTypeOf(context.schema, typeField.type, ifaceField.type)) {
274
- context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expects type ") + "".concat(inspect(ifaceField.type), " but ").concat(type.name, ".").concat(fieldName, " ") + "is type ".concat(inspect(typeField.type), "."), [ifaceField.astNode.type, typeField.astNode.type]);
280
+ var _ifaceField$astNode, _typeField$astNode;
281
+
282
+ context.reportError("Interface field ".concat(iface.name, ".").concat(fieldName, " expects type ") + "".concat(inspect(ifaceField.type), " but ").concat(type.name, ".").concat(fieldName, " ") + "is type ".concat(inspect(typeField.type), "."), [// istanbul ignore next (TODO need to write coverage tests)
283
+ (_ifaceField$astNode = ifaceField.astNode) === null || _ifaceField$astNode === void 0 ? void 0 : _ifaceField$astNode.type, // istanbul ignore next (TODO need to write coverage tests)
284
+ (_typeField$astNode = typeField.astNode) === null || _typeField$astNode === void 0 ? void 0 : _typeField$astNode.type]);
275
285
  } // Assert each interface field arg is implemented.
276
286
 
277
287
 
@@ -291,7 +301,11 @@ function validateTypeImplementsInterface(context, type, iface) {
291
301
 
292
302
 
293
303
  if (!isEqualType(ifaceArg.type, typeArg.type)) {
294
- context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expects type ".concat(inspect(ifaceArg.type), " but ") + "".concat(type.name, ".").concat(fieldName, "(").concat(argName, ":) is type ") + "".concat(inspect(typeArg.type), "."), [ifaceArg.astNode.type, typeArg.astNode.type]);
304
+ var _ifaceArg$astNode, _typeArg$astNode;
305
+
306
+ context.reportError("Interface field argument ".concat(iface.name, ".").concat(fieldName, "(").concat(argName, ":) ") + "expects type ".concat(inspect(ifaceArg.type), " but ") + "".concat(type.name, ".").concat(fieldName, "(").concat(argName, ":) is type ") + "".concat(inspect(typeArg.type), "."), [// istanbul ignore next (TODO need to write coverage tests)
307
+ (_ifaceArg$astNode = ifaceArg.astNode) === null || _ifaceArg$astNode === void 0 ? void 0 : _ifaceArg$astNode.type, // istanbul ignore next (TODO need to write coverage tests)
308
+ (_typeArg$astNode = typeArg.astNode) === null || _typeArg$astNode === void 0 ? void 0 : _typeArg$astNode.type]);
295
309
  } // TODO: validate default values?
296
310
 
297
311
  };
@@ -455,7 +469,7 @@ function getAllNodes(object) {
455
469
  }
456
470
 
457
471
  function getAllSubNodes(object, getter) {
458
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
472
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
459
473
  return flatMap(getAllNodes(object), function (item) {
460
474
  var _getter;
461
475
 
@@ -1,4 +1,5 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
+
2
3
  import { Visitor } from '../language/visitor';
3
4
  import { ASTNode, ASTKindToNode, FieldNode } from '../language/ast';
4
5
  import { GraphQLSchema } from '../type/schema';
@@ -1,4 +1,5 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
+
2
3
  import { ValueNode } from '../language/ast';
3
4
  import { GraphQLInputType } from '../type/definition';
4
5
 
@@ -127,9 +127,9 @@ function astFromValue(value, type) {
127
127
  kind: _kinds.Kind.OBJECT,
128
128
  fields: fieldNodes
129
129
  };
130
- }
130
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
131
+
131
132
 
132
- /* istanbul ignore else */
133
133
  if ((0, _definition.isLeafType)(type)) {
134
134
  // Since value is an internally represented value, it must be serialized
135
135
  // to an externally represented value before converting into an AST.
@@ -183,11 +183,10 @@ function astFromValue(value, type) {
183
183
  }
184
184
 
185
185
  throw new TypeError("Cannot convert value to AST: ".concat((0, _inspect.default)(serialized), "."));
186
- } // Not reachable. All possible input types have been considered.
186
+ } // istanbul ignore next (Not reachable. All possible input types have been considered)
187
187
 
188
188
 
189
- /* istanbul ignore next */
190
- (0, _invariant.default)(false, 'Unexpected input type: ' + (0, _inspect.default)(type));
189
+ false || (0, _invariant.default)(0, 'Unexpected input type: ' + (0, _inspect.default)(type));
191
190
  }
192
191
  /**
193
192
  * IntValue:
@@ -101,6 +101,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
101
101
  return { kind: Kind.OBJECT, fields: fieldNodes };
102
102
  }
103
103
 
104
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
104
105
  if (isLeafType(type)) {
105
106
  // Since value is an internally represented value, it must be serialized
106
107
  // to an externally represented value before converting into an AST.
@@ -142,7 +143,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
142
143
  throw new TypeError(`Cannot convert value to AST: ${inspect(serialized)}.`);
143
144
  }
144
145
 
145
- // Not reachable. All possible input types have been considered.
146
+ // istanbul ignore next (Not reachable. All possible input types have been considered)
146
147
  invariant(false, 'Unexpected input type: ' + inspect((type: empty)));
147
148
  }
148
149
 
@@ -109,9 +109,9 @@ export function astFromValue(value, type) {
109
109
  kind: Kind.OBJECT,
110
110
  fields: fieldNodes
111
111
  };
112
- }
112
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
113
+
113
114
 
114
- /* istanbul ignore else */
115
115
  if (isLeafType(type)) {
116
116
  // Since value is an internally represented value, it must be serialized
117
117
  // to an externally represented value before converting into an AST.
@@ -165,11 +165,10 @@ export function astFromValue(value, type) {
165
165
  }
166
166
 
167
167
  throw new TypeError("Cannot convert value to AST: ".concat(inspect(serialized), "."));
168
- } // Not reachable. All possible input types have been considered.
168
+ } // istanbul ignore next (Not reachable. All possible input types have been considered)
169
169
 
170
170
 
171
- /* istanbul ignore next */
172
- invariant(false, 'Unexpected input type: ' + inspect(type));
171
+ false || invariant(0, 'Unexpected input type: ' + inspect(type));
173
172
  }
174
173
  /**
175
174
  * IntValue:
@@ -45,6 +45,14 @@ function buildASTSchema(documentAST, options) {
45
45
  (0, _validate.assertValidSDL)(documentAST);
46
46
  }
47
47
 
48
+ var emptySchemaConfig = {
49
+ description: undefined,
50
+ types: [],
51
+ directives: [],
52
+ extensions: undefined,
53
+ extensionASTNodes: [],
54
+ assumeValid: false
55
+ };
48
56
  var config = (0, _extendSchema.extendSchemaImpl)(emptySchemaConfig, documentAST, options);
49
57
 
50
58
  if (config.astNode == null) {
@@ -90,17 +98,20 @@ function buildASTSchema(documentAST, options) {
90
98
  directives.push(_directives.GraphQLDeprecatedDirective);
91
99
  }
92
100
 
101
+ if (!directives.some(function (directive) {
102
+ return directive.name === 'specifiedBy';
103
+ })) {
104
+ directives.push(_directives.GraphQLSpecifiedByDirective);
105
+ }
106
+
93
107
  return new _schema.GraphQLSchema(config);
94
108
  }
95
-
96
- var emptySchemaConfig = new _schema.GraphQLSchema({
97
- directives: []
98
- }).toConfig();
99
109
  /**
100
110
  * A helper function to build a GraphQLSchema directly from a source
101
111
  * document.
102
112
  */
103
113
 
114
+
104
115
  function buildSchema(source, options) {
105
116
  var document = (0, _parser.parse)(source, {
106
117
  noLocation: options === null || options === void 0 ? void 0 : options.noLocation,
@@ -17,6 +17,7 @@ import {
17
17
  GraphQLSkipDirective,
18
18
  GraphQLIncludeDirective,
19
19
  GraphQLDeprecatedDirective,
20
+ GraphQLSpecifiedByDirective,
20
21
  } from '../type/directives';
21
22
 
22
23
  import { extendSchemaImpl } from './extendSchema';
@@ -71,6 +72,14 @@ export function buildASTSchema(
71
72
  assertValidSDL(documentAST);
72
73
  }
73
74
 
75
+ const emptySchemaConfig = {
76
+ description: undefined,
77
+ types: [],
78
+ directives: [],
79
+ extensions: undefined,
80
+ extensionASTNodes: [],
81
+ assumeValid: false,
82
+ };
74
83
  const config = extendSchemaImpl(emptySchemaConfig, documentAST, options);
75
84
 
76
85
  if (config.astNode == null) {
@@ -106,11 +115,13 @@ export function buildASTSchema(
106
115
  directives.push(GraphQLDeprecatedDirective);
107
116
  }
108
117
 
118
+ if (!directives.some((directive) => directive.name === 'specifiedBy')) {
119
+ directives.push(GraphQLSpecifiedByDirective);
120
+ }
121
+
109
122
  return new GraphQLSchema(config);
110
123
  }
111
124
 
112
- const emptySchemaConfig = new GraphQLSchema({ directives: [] }).toConfig();
113
-
114
125
  /**
115
126
  * A helper function to build a GraphQLSchema directly from a source
116
127
  * document.
@@ -3,7 +3,7 @@ import { Kind } from "../language/kinds.mjs";
3
3
  import { parse } from "../language/parser.mjs";
4
4
  import { assertValidSDL } from "../validation/validate.mjs";
5
5
  import { GraphQLSchema } from "../type/schema.mjs";
6
- import { GraphQLSkipDirective, GraphQLIncludeDirective, GraphQLDeprecatedDirective } from "../type/directives.mjs";
6
+ import { GraphQLSkipDirective, GraphQLIncludeDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective } from "../type/directives.mjs";
7
7
  import { extendSchemaImpl } from "./extendSchema.mjs";
8
8
 
9
9
  /**
@@ -29,6 +29,14 @@ export function buildASTSchema(documentAST, options) {
29
29
  assertValidSDL(documentAST);
30
30
  }
31
31
 
32
+ var emptySchemaConfig = {
33
+ description: undefined,
34
+ types: [],
35
+ directives: [],
36
+ extensions: undefined,
37
+ extensionASTNodes: [],
38
+ assumeValid: false
39
+ };
32
40
  var config = extendSchemaImpl(emptySchemaConfig, documentAST, options);
33
41
 
34
42
  if (config.astNode == null) {
@@ -74,11 +82,14 @@ export function buildASTSchema(documentAST, options) {
74
82
  directives.push(GraphQLDeprecatedDirective);
75
83
  }
76
84
 
85
+ if (!directives.some(function (directive) {
86
+ return directive.name === 'specifiedBy';
87
+ })) {
88
+ directives.push(GraphQLSpecifiedByDirective);
89
+ }
90
+
77
91
  return new GraphQLSchema(config);
78
92
  }
79
- var emptySchemaConfig = new GraphQLSchema({
80
- directives: []
81
- }).toConfig();
82
93
  /**
83
94
  * A helper function to build a GraphQLSchema directly from a source
84
95
  * document.
@@ -162,7 +162,8 @@ function buildClientSchema(introspection, options) {
162
162
  function buildScalarDef(scalarIntrospection) {
163
163
  return new _definition.GraphQLScalarType({
164
164
  name: scalarIntrospection.name,
165
- description: scalarIntrospection.description
165
+ description: scalarIntrospection.description,
166
+ specifiedByUrl: scalarIntrospection.specifiedByUrl
166
167
  });
167
168
  }
168
169
 
@@ -200,6 +200,7 @@ export function buildClientSchema(
200
200
  return new GraphQLScalarType({
201
201
  name: scalarIntrospection.name,
202
202
  description: scalarIntrospection.description,
203
+ specifiedByUrl: scalarIntrospection.specifiedByUrl,
203
204
  });
204
205
  }
205
206
 
@@ -142,7 +142,8 @@ export function buildClientSchema(introspection, options) {
142
142
  function buildScalarDef(scalarIntrospection) {
143
143
  return new GraphQLScalarType({
144
144
  name: scalarIntrospection.name,
145
- description: scalarIntrospection.description
145
+ description: scalarIntrospection.description,
146
+ specifiedByUrl: scalarIntrospection.specifiedByUrl
146
147
  });
147
148
  }
148
149
 
@@ -117,9 +117,9 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
117
117
  }
118
118
 
119
119
  return coercedValue;
120
- }
120
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
121
+
121
122
 
122
- /* istanbul ignore else */
123
123
  if ((0, _definition.isLeafType)(type)) {
124
124
  var parseResult; // Scalars and Enums determine if a input value is valid via parseValue(),
125
125
  // which can throw to indicate failure. If it throws, maintain a reference
@@ -142,9 +142,8 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
142
142
  }
143
143
 
144
144
  return parseResult;
145
- } // Not reachable. All possible input types have been considered.
145
+ } // istanbul ignore next (Not reachable. All possible input types have been considered)
146
146
 
147
147
 
148
- /* istanbul ignore next */
149
- (0, _invariant.default)(false, 'Unexpected input type: ' + (0, _inspect.default)(type));
148
+ false || (0, _invariant.default)(0, 'Unexpected input type: ' + (0, _inspect.default)(type));
150
149
  }
@@ -148,6 +148,7 @@ function coerceInputValueImpl(
148
148
  return coercedValue;
149
149
  }
150
150
 
151
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
151
152
  if (isLeafType(type)) {
152
153
  let parseResult;
153
154
 
@@ -185,6 +186,6 @@ function coerceInputValueImpl(
185
186
  return parseResult;
186
187
  }
187
188
 
188
- // Not reachable. All possible input types have been considered.
189
+ // istanbul ignore next (Not reachable. All possible input types have been considered)
189
190
  invariant(false, 'Unexpected input type: ' + inspect((type: empty)));
190
191
  }
@@ -97,9 +97,9 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
97
97
  }
98
98
 
99
99
  return coercedValue;
100
- }
100
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
101
+
101
102
 
102
- /* istanbul ignore else */
103
103
  if (isLeafType(type)) {
104
104
  var parseResult; // Scalars and Enums determine if a input value is valid via parseValue(),
105
105
  // which can throw to indicate failure. If it throws, maintain a reference
@@ -122,9 +122,8 @@ function coerceInputValueImpl(inputValue, type, onError, path) {
122
122
  }
123
123
 
124
124
  return parseResult;
125
- } // Not reachable. All possible input types have been considered.
125
+ } // istanbul ignore next (Not reachable. All possible input types have been considered)
126
126
 
127
127
 
128
- /* istanbul ignore next */
129
- invariant(false, 'Unexpected input type: ' + inspect(type));
128
+ false || invariant(0, 'Unexpected input type: ' + inspect(type));
130
129
  }
@@ -1,4 +1,5 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
+
2
3
  import { Location, DocumentNode, StringValueNode } from '../language/ast';
3
4
  import {
4
5
  GraphQLSchemaValidationOptions,