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
@@ -138,17 +138,17 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
138
138
  typeMap[name] = (_stdTypeMap$name = stdTypeMap[name]) !== null && _stdTypeMap$name !== void 0 ? _stdTypeMap$name : buildType(typeNode);
139
139
  }
140
140
 
141
- var operationTypes = _objectSpread({
141
+ var operationTypes = _objectSpread(_objectSpread({
142
142
  // Get the extended root operation types.
143
143
  query: schemaConfig.query && replaceNamedType(schemaConfig.query),
144
144
  mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation),
145
145
  subscription: schemaConfig.subscription && replaceNamedType(schemaConfig.subscription)
146
- }, schemaDef && getOperationTypes([schemaDef]), {}, getOperationTypes(schemaExtensions)); // Then produce and return a Schema config with these types.
146
+ }, schemaDef && getOperationTypes([schemaDef])), getOperationTypes(schemaExtensions)); // Then produce and return a Schema config with these types.
147
147
 
148
148
 
149
- return _objectSpread({
149
+ return _objectSpread(_objectSpread({
150
150
  description: (_schemaDef = schemaDef) === null || _schemaDef === void 0 ? void 0 : (_schemaDef$descriptio = _schemaDef.description) === null || _schemaDef$descriptio === void 0 ? void 0 : _schemaDef$descriptio.value
151
- }, operationTypes, {
151
+ }, operationTypes), {}, {
152
152
  types: (0, _objectValues.default)(typeMap),
153
153
  directives: [].concat(schemaConfig.directives.map(replaceDirective), directiveDefs.map(buildDirective)),
154
154
  extensions: undefined,
@@ -177,7 +177,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
177
177
 
178
178
  function replaceDirective(directive) {
179
179
  var config = directive.toConfig();
180
- return new _directives.GraphQLDirective(_objectSpread({}, config, {
180
+ return new _directives.GraphQLDirective(_objectSpread(_objectSpread({}, config), {}, {
181
181
  args: (0, _mapValue.default)(config.args, extendArg)
182
182
  }));
183
183
  }
@@ -206,16 +206,15 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
206
206
 
207
207
  if ((0, _definition.isEnumType)(type)) {
208
208
  return extendEnumType(type);
209
- }
209
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
210
+
210
211
 
211
- /* istanbul ignore else */
212
212
  if ((0, _definition.isInputObjectType)(type)) {
213
213
  return extendInputObjectType(type);
214
- } // Not reachable. All possible types have been considered.
214
+ } // istanbul ignore next (Not reachable. All possible types have been considered)
215
215
 
216
216
 
217
- /* istanbul ignore next */
218
- (0, _invariant.default)(false, 'Unexpected type: ' + (0, _inspect.default)(type));
217
+ false || (0, _invariant.default)(0, 'Unexpected type: ' + (0, _inspect.default)(type));
219
218
  }
220
219
 
221
220
  function extendInputObjectType(type) {
@@ -223,13 +222,13 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
223
222
 
224
223
  var config = type.toConfig();
225
224
  var extensions = (_typeExtensionsMap$co = typeExtensionsMap[config.name]) !== null && _typeExtensionsMap$co !== void 0 ? _typeExtensionsMap$co : [];
226
- return new _definition.GraphQLInputObjectType(_objectSpread({}, config, {
225
+ return new _definition.GraphQLInputObjectType(_objectSpread(_objectSpread({}, config), {}, {
227
226
  fields: function fields() {
228
- return _objectSpread({}, (0, _mapValue.default)(config.fields, function (field) {
229
- return _objectSpread({}, field, {
227
+ return _objectSpread(_objectSpread({}, (0, _mapValue.default)(config.fields, function (field) {
228
+ return _objectSpread(_objectSpread({}, field), {}, {
230
229
  type: replaceType(field.type)
231
230
  });
232
- }), {}, buildInputFieldMap(extensions));
231
+ })), buildInputFieldMap(extensions));
233
232
  },
234
233
  extensionASTNodes: config.extensionASTNodes.concat(extensions)
235
234
  }));
@@ -240,8 +239,8 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
240
239
 
241
240
  var config = type.toConfig();
242
241
  var extensions = (_typeExtensionsMap$ty = typeExtensionsMap[type.name]) !== null && _typeExtensionsMap$ty !== void 0 ? _typeExtensionsMap$ty : [];
243
- return new _definition.GraphQLEnumType(_objectSpread({}, config, {
244
- values: _objectSpread({}, config.values, {}, buildEnumValueMap(extensions)),
242
+ return new _definition.GraphQLEnumType(_objectSpread(_objectSpread({}, config), {}, {
243
+ values: _objectSpread(_objectSpread({}, config.values), buildEnumValueMap(extensions)),
245
244
  extensionASTNodes: config.extensionASTNodes.concat(extensions)
246
245
  }));
247
246
  }
@@ -251,7 +250,17 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
251
250
 
252
251
  var config = type.toConfig();
253
252
  var extensions = (_typeExtensionsMap$co2 = typeExtensionsMap[config.name]) !== null && _typeExtensionsMap$co2 !== void 0 ? _typeExtensionsMap$co2 : [];
254
- return new _definition.GraphQLScalarType(_objectSpread({}, config, {
253
+ var specifiedByUrl = config.specifiedByUrl;
254
+
255
+ for (var _i8 = 0; _i8 < extensions.length; _i8++) {
256
+ var _getSpecifiedByUrl;
257
+
258
+ var extensionNode = extensions[_i8];
259
+ specifiedByUrl = (_getSpecifiedByUrl = getSpecifiedByUrl(extensionNode)) !== null && _getSpecifiedByUrl !== void 0 ? _getSpecifiedByUrl : specifiedByUrl;
260
+ }
261
+
262
+ return new _definition.GraphQLScalarType(_objectSpread(_objectSpread({}, config), {}, {
263
+ specifiedByUrl: specifiedByUrl,
255
264
  extensionASTNodes: config.extensionASTNodes.concat(extensions)
256
265
  }));
257
266
  }
@@ -261,12 +270,12 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
261
270
 
262
271
  var config = type.toConfig();
263
272
  var extensions = (_typeExtensionsMap$co3 = typeExtensionsMap[config.name]) !== null && _typeExtensionsMap$co3 !== void 0 ? _typeExtensionsMap$co3 : [];
264
- return new _definition.GraphQLObjectType(_objectSpread({}, config, {
273
+ return new _definition.GraphQLObjectType(_objectSpread(_objectSpread({}, config), {}, {
265
274
  interfaces: function interfaces() {
266
275
  return [].concat(type.getInterfaces().map(replaceNamedType), buildInterfaces(extensions));
267
276
  },
268
277
  fields: function fields() {
269
- return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), {}, buildFieldMap(extensions));
278
+ return _objectSpread(_objectSpread({}, (0, _mapValue.default)(config.fields, extendField)), buildFieldMap(extensions));
270
279
  },
271
280
  extensionASTNodes: config.extensionASTNodes.concat(extensions)
272
281
  }));
@@ -277,12 +286,12 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
277
286
 
278
287
  var config = type.toConfig();
279
288
  var extensions = (_typeExtensionsMap$co4 = typeExtensionsMap[config.name]) !== null && _typeExtensionsMap$co4 !== void 0 ? _typeExtensionsMap$co4 : [];
280
- return new _definition.GraphQLInterfaceType(_objectSpread({}, config, {
289
+ return new _definition.GraphQLInterfaceType(_objectSpread(_objectSpread({}, config), {}, {
281
290
  interfaces: function interfaces() {
282
291
  return [].concat(type.getInterfaces().map(replaceNamedType), buildInterfaces(extensions));
283
292
  },
284
293
  fields: function fields() {
285
- return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), {}, buildFieldMap(extensions));
294
+ return _objectSpread(_objectSpread({}, (0, _mapValue.default)(config.fields, extendField)), buildFieldMap(extensions));
286
295
  },
287
296
  extensionASTNodes: config.extensionASTNodes.concat(extensions)
288
297
  }));
@@ -293,7 +302,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
293
302
 
294
303
  var config = type.toConfig();
295
304
  var extensions = (_typeExtensionsMap$co5 = typeExtensionsMap[config.name]) !== null && _typeExtensionsMap$co5 !== void 0 ? _typeExtensionsMap$co5 : [];
296
- return new _definition.GraphQLUnionType(_objectSpread({}, config, {
305
+ return new _definition.GraphQLUnionType(_objectSpread(_objectSpread({}, config), {}, {
297
306
  types: function types() {
298
307
  return [].concat(type.getTypes().map(replaceNamedType), buildUnionTypes(extensions));
299
308
  },
@@ -302,14 +311,14 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
302
311
  }
303
312
 
304
313
  function extendField(field) {
305
- return _objectSpread({}, field, {
314
+ return _objectSpread(_objectSpread({}, field), {}, {
306
315
  type: replaceType(field.type),
307
316
  args: (0, _mapValue.default)(field.args, extendArg)
308
317
  });
309
318
  }
310
319
 
311
320
  function extendArg(arg) {
312
- return _objectSpread({}, arg, {
321
+ return _objectSpread(_objectSpread({}, arg), {}, {
313
322
  type: replaceType(arg.type)
314
323
  });
315
324
  }
@@ -317,16 +326,15 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
317
326
  function getOperationTypes(nodes) {
318
327
  var opTypes = {};
319
328
 
320
- for (var _i8 = 0; _i8 < nodes.length; _i8++) {
329
+ for (var _i10 = 0; _i10 < nodes.length; _i10++) {
321
330
  var _node$operationTypes;
322
331
 
323
- var node = nodes[_i8];
324
-
325
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
332
+ var node = nodes[_i10];
333
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
326
334
  var operationTypesNodes = (_node$operationTypes = node.operationTypes) !== null && _node$operationTypes !== void 0 ? _node$operationTypes : [];
327
335
 
328
- for (var _i10 = 0; _i10 < operationTypesNodes.length; _i10++) {
329
- var operationType = operationTypesNodes[_i10];
336
+ for (var _i12 = 0; _i12 < operationTypesNodes.length; _i12++) {
337
+ var operationType = operationTypesNodes[_i12];
330
338
  opTypes[operationType.operation] = getNamedType(operationType.type);
331
339
  }
332
340
  } // Note: While this could make early assertions to get the correctly
@@ -380,16 +388,15 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
380
388
  function buildFieldMap(nodes) {
381
389
  var fieldConfigMap = Object.create(null);
382
390
 
383
- for (var _i12 = 0; _i12 < nodes.length; _i12++) {
391
+ for (var _i14 = 0; _i14 < nodes.length; _i14++) {
384
392
  var _node$fields;
385
393
 
386
- var node = nodes[_i12];
387
-
388
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
394
+ var node = nodes[_i14];
395
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
389
396
  var nodeFields = (_node$fields = node.fields) !== null && _node$fields !== void 0 ? _node$fields : [];
390
397
 
391
- for (var _i14 = 0; _i14 < nodeFields.length; _i14++) {
392
- var field = nodeFields[_i14];
398
+ for (var _i16 = 0; _i16 < nodeFields.length; _i16++) {
399
+ var field = nodeFields[_i16];
393
400
  fieldConfigMap[field.name.value] = {
394
401
  // Note: While this could make assertions to get the correctly typed
395
402
  // value, that would throw immediately while type system validation
@@ -407,12 +414,12 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
407
414
  }
408
415
 
409
416
  function buildArgumentMap(args) {
410
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
417
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
411
418
  var argsNodes = args !== null && args !== void 0 ? args : [];
412
419
  var argConfigMap = Object.create(null);
413
420
 
414
- for (var _i16 = 0; _i16 < argsNodes.length; _i16++) {
415
- var arg = argsNodes[_i16];
421
+ for (var _i18 = 0; _i18 < argsNodes.length; _i18++) {
422
+ var arg = argsNodes[_i18];
416
423
  // Note: While this could make assertions to get the correctly typed
417
424
  // value, that would throw immediately while type system validation
418
425
  // with validateSchema() will produce more actionable results.
@@ -431,16 +438,15 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
431
438
  function buildInputFieldMap(nodes) {
432
439
  var inputFieldMap = Object.create(null);
433
440
 
434
- for (var _i18 = 0; _i18 < nodes.length; _i18++) {
441
+ for (var _i20 = 0; _i20 < nodes.length; _i20++) {
435
442
  var _node$fields2;
436
443
 
437
- var node = nodes[_i18];
438
-
439
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
444
+ var node = nodes[_i20];
445
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
440
446
  var fieldsNodes = (_node$fields2 = node.fields) !== null && _node$fields2 !== void 0 ? _node$fields2 : [];
441
447
 
442
- for (var _i20 = 0; _i20 < fieldsNodes.length; _i20++) {
443
- var field = fieldsNodes[_i20];
448
+ for (var _i22 = 0; _i22 < fieldsNodes.length; _i22++) {
449
+ var field = fieldsNodes[_i22];
444
450
  // Note: While this could make assertions to get the correctly typed
445
451
  // value, that would throw immediately while type system validation
446
452
  // with validateSchema() will produce more actionable results.
@@ -460,16 +466,15 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
460
466
  function buildEnumValueMap(nodes) {
461
467
  var enumValueMap = Object.create(null);
462
468
 
463
- for (var _i22 = 0; _i22 < nodes.length; _i22++) {
469
+ for (var _i24 = 0; _i24 < nodes.length; _i24++) {
464
470
  var _node$values;
465
471
 
466
- var node = nodes[_i22];
467
-
468
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
472
+ var node = nodes[_i24];
473
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
469
474
  var valuesNodes = (_node$values = node.values) !== null && _node$values !== void 0 ? _node$values : [];
470
475
 
471
- for (var _i24 = 0; _i24 < valuesNodes.length; _i24++) {
472
- var value = valuesNodes[_i24];
476
+ for (var _i26 = 0; _i26 < valuesNodes.length; _i26++) {
477
+ var value = valuesNodes[_i26];
473
478
  enumValueMap[value.name.value] = {
474
479
  description: getDescription(value, options),
475
480
  deprecationReason: getDeprecationReason(value),
@@ -484,16 +489,15 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
484
489
  function buildInterfaces(nodes) {
485
490
  var interfaces = [];
486
491
 
487
- for (var _i26 = 0; _i26 < nodes.length; _i26++) {
492
+ for (var _i28 = 0; _i28 < nodes.length; _i28++) {
488
493
  var _node$interfaces;
489
494
 
490
- var node = nodes[_i26];
491
-
492
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
495
+ var node = nodes[_i28];
496
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
493
497
  var interfacesNodes = (_node$interfaces = node.interfaces) !== null && _node$interfaces !== void 0 ? _node$interfaces : [];
494
498
 
495
- for (var _i28 = 0; _i28 < interfacesNodes.length; _i28++) {
496
- var type = interfacesNodes[_i28];
499
+ for (var _i30 = 0; _i30 < interfacesNodes.length; _i30++) {
500
+ var type = interfacesNodes[_i30];
497
501
  // Note: While this could make assertions to get the correctly typed
498
502
  // values below, that would throw immediately while type system
499
503
  // validation with validateSchema() will produce more actionable
@@ -508,16 +512,15 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
508
512
  function buildUnionTypes(nodes) {
509
513
  var types = [];
510
514
 
511
- for (var _i30 = 0; _i30 < nodes.length; _i30++) {
515
+ for (var _i32 = 0; _i32 < nodes.length; _i32++) {
512
516
  var _node$types;
513
517
 
514
- var node = nodes[_i30];
515
-
516
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
518
+ var node = nodes[_i32];
519
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
517
520
  var typeNodes = (_node$types = node.types) !== null && _node$types !== void 0 ? _node$types : [];
518
521
 
519
- for (var _i32 = 0; _i32 < typeNodes.length; _i32++) {
520
- var type = typeNodes[_i32];
522
+ for (var _i34 = 0; _i34 < typeNodes.length; _i34++) {
523
+ var type = typeNodes[_i34];
521
524
  // Note: While this could make assertions to get the correctly typed
522
525
  // values below, that would throw immediately while type system
523
526
  // validation with validateSchema() will produce more actionable
@@ -613,6 +616,7 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
613
616
  return new _definition.GraphQLScalarType({
614
617
  name: name,
615
618
  description: description,
619
+ specifiedByUrl: getSpecifiedByUrl(astNode),
616
620
  astNode: astNode,
617
621
  extensionASTNodes: _extensionASTNodes4
618
622
  });
@@ -634,11 +638,10 @@ function extendSchemaImpl(schemaConfig, documentAST, options) {
634
638
  extensionASTNodes: _extensionASTNodes5
635
639
  });
636
640
  }
637
- } // Not reachable. All possible type definition nodes have been considered.
641
+ } // istanbul ignore next (Not reachable. All possible type definition nodes have been considered)
638
642
 
639
643
 
640
- /* istanbul ignore next */
641
- (0, _invariant.default)(false, 'Unexpected type definition node: ' + (0, _inspect.default)(astNode));
644
+ false || (0, _invariant.default)(0, 'Unexpected type definition node: ' + (0, _inspect.default)(astNode));
642
645
  }
643
646
  }
644
647
 
@@ -654,6 +657,15 @@ function getDeprecationReason(node) {
654
657
  var deprecated = (0, _values.getDirectiveValues)(_directives.GraphQLDeprecatedDirective, node);
655
658
  return deprecated === null || deprecated === void 0 ? void 0 : deprecated.reason;
656
659
  }
660
+ /**
661
+ * Given a scalar node, returns the string value for the specifiedByUrl.
662
+ */
663
+
664
+
665
+ function getSpecifiedByUrl(node) {
666
+ var specifiedBy = (0, _values.getDirectiveValues)(_directives.GraphQLSpecifiedByDirective, node);
667
+ return specifiedBy === null || specifiedBy === void 0 ? void 0 : specifiedBy.url;
668
+ }
657
669
  /**
658
670
  * Given an ast node, returns its string description.
659
671
  * @deprecated: provided to ease adoption and will be removed in v16.
@@ -39,6 +39,8 @@ import {
39
39
  type EnumTypeExtensionNode,
40
40
  type EnumValueDefinitionNode,
41
41
  type DirectiveDefinitionNode,
42
+ type ScalarTypeDefinitionNode,
43
+ type ScalarTypeExtensionNode,
42
44
  } from '../language/ast';
43
45
 
44
46
  import { assertValidSDLExtension } from '../validation/validate';
@@ -50,6 +52,7 @@ import { introspectionTypes, isIntrospectionType } from '../type/introspection';
50
52
  import {
51
53
  GraphQLDirective,
52
54
  GraphQLDeprecatedDirective,
55
+ GraphQLSpecifiedByDirective,
53
56
  } from '../type/directives';
54
57
  import {
55
58
  type GraphQLSchemaValidationOptions,
@@ -279,11 +282,12 @@ export function extendSchemaImpl(
279
282
  if (isEnumType(type)) {
280
283
  return extendEnumType(type);
281
284
  }
285
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
282
286
  if (isInputObjectType(type)) {
283
287
  return extendInputObjectType(type);
284
288
  }
285
289
 
286
- // Not reachable. All possible types have been considered.
290
+ // istanbul ignore next (Not reachable. All possible types have been considered)
287
291
  invariant(false, 'Unexpected type: ' + inspect((type: empty)));
288
292
  }
289
293
 
@@ -324,8 +328,14 @@ export function extendSchemaImpl(
324
328
  const config = type.toConfig();
325
329
  const extensions = typeExtensionsMap[config.name] ?? [];
326
330
 
331
+ let specifiedByUrl = config.specifiedByUrl;
332
+ for (const extensionNode of extensions) {
333
+ specifiedByUrl = getSpecifiedByUrl(extensionNode) ?? specifiedByUrl;
334
+ }
335
+
327
336
  return new GraphQLScalarType({
328
337
  ...config,
338
+ specifiedByUrl,
329
339
  extensionASTNodes: config.extensionASTNodes.concat(extensions),
330
340
  });
331
341
  }
@@ -406,7 +416,7 @@ export function extendSchemaImpl(
406
416
  |} {
407
417
  const opTypes = {};
408
418
  for (const node of nodes) {
409
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
419
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
410
420
  const operationTypesNodes = node.operationTypes ?? [];
411
421
 
412
422
  for (const operationType of operationTypesNodes) {
@@ -465,7 +475,7 @@ export function extendSchemaImpl(
465
475
  ): GraphQLFieldConfigMap<mixed, mixed> {
466
476
  const fieldConfigMap = Object.create(null);
467
477
  for (const node of nodes) {
468
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
478
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
469
479
  const nodeFields = node.fields ?? [];
470
480
 
471
481
  for (const field of nodeFields) {
@@ -487,7 +497,7 @@ export function extendSchemaImpl(
487
497
  function buildArgumentMap(
488
498
  args: ?$ReadOnlyArray<InputValueDefinitionNode>,
489
499
  ): GraphQLFieldConfigArgumentMap {
490
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
500
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
491
501
  const argsNodes = args ?? [];
492
502
 
493
503
  const argConfigMap = Object.create(null);
@@ -514,7 +524,7 @@ export function extendSchemaImpl(
514
524
  ): GraphQLInputFieldConfigMap {
515
525
  const inputFieldMap = Object.create(null);
516
526
  for (const node of nodes) {
517
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
527
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
518
528
  const fieldsNodes = node.fields ?? [];
519
529
 
520
530
  for (const field of fieldsNodes) {
@@ -539,7 +549,7 @@ export function extendSchemaImpl(
539
549
  ): GraphQLEnumValueConfigMap {
540
550
  const enumValueMap = Object.create(null);
541
551
  for (const node of nodes) {
542
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
552
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
543
553
  const valuesNodes = node.values ?? [];
544
554
 
545
555
  for (const value of valuesNodes) {
@@ -563,7 +573,7 @@ export function extendSchemaImpl(
563
573
  ): Array<GraphQLInterfaceType> {
564
574
  const interfaces = [];
565
575
  for (const node of nodes) {
566
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
576
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
567
577
  const interfacesNodes = node.interfaces ?? [];
568
578
 
569
579
  for (const type of interfacesNodes) {
@@ -582,7 +592,7 @@ export function extendSchemaImpl(
582
592
  ): Array<GraphQLObjectType> {
583
593
  const types = [];
584
594
  for (const node of nodes) {
585
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
595
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
586
596
  const typeNodes = node.types ?? [];
587
597
 
588
598
  for (const type of typeNodes) {
@@ -658,6 +668,7 @@ export function extendSchemaImpl(
658
668
  return new GraphQLScalarType({
659
669
  name,
660
670
  description,
671
+ specifiedByUrl: getSpecifiedByUrl(astNode),
661
672
  astNode,
662
673
  extensionASTNodes,
663
674
  });
@@ -676,7 +687,7 @@ export function extendSchemaImpl(
676
687
  }
677
688
  }
678
689
 
679
- // Not reachable. All possible type definition nodes have been considered.
690
+ // istanbul ignore next (Not reachable. All possible type definition nodes have been considered)
680
691
  invariant(
681
692
  false,
682
693
  'Unexpected type definition node: ' + inspect((astNode: empty)),
@@ -700,6 +711,16 @@ function getDeprecationReason(
700
711
  return (deprecated?.reason: any);
701
712
  }
702
713
 
714
+ /**
715
+ * Given a scalar node, returns the string value for the specifiedByUrl.
716
+ */
717
+ function getSpecifiedByUrl(
718
+ node: ScalarTypeDefinitionNode | ScalarTypeExtensionNode,
719
+ ): ?string {
720
+ const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node);
721
+ return (specifiedBy?.url: any);
722
+ }
723
+
703
724
  /**
704
725
  * Given an ast node, returns its string description.
705
726
  * @deprecated: provided to ease adoption and will be removed in v16.