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
@@ -17,7 +17,7 @@ import instanceOf from "../jsutils/instanceOf.mjs";
17
17
  import didYouMean from "../jsutils/didYouMean.mjs";
18
18
  import isObjectLike from "../jsutils/isObjectLike.mjs";
19
19
  import identityFunc from "../jsutils/identityFunc.mjs";
20
- import defineToJSON from "../jsutils/defineToJSON.mjs";
20
+ import defineInspect from "../jsutils/defineInspect.mjs";
21
21
  import suggestionList from "../jsutils/suggestionList.mjs";
22
22
  import { Kind } from "../language/kinds.mjs";
23
23
  import { print } from "../language/printer.mjs";
@@ -236,12 +236,17 @@ GraphQLList.prototype.toString = function toString() {
236
236
  return '[' + String(this.ofType) + ']';
237
237
  };
238
238
 
239
+ GraphQLList.prototype.toJSON = function toJSON() {
240
+ return this.toString();
241
+ };
242
+
239
243
  Object.defineProperty(GraphQLList.prototype, SYMBOL_TO_STRING_TAG, {
240
244
  get: function get() {
241
245
  return 'GraphQLList';
242
246
  }
243
- });
244
- defineToJSON(GraphQLList);
247
+ }); // Print a simplified form when appearing in `inspect` and `util.inspect`.
248
+
249
+ defineInspect(GraphQLList);
245
250
  /**
246
251
  * Non-Null Type Wrapper
247
252
  *
@@ -285,12 +290,17 @@ GraphQLNonNull.prototype.toString = function toString() {
285
290
  return String(this.ofType) + '!';
286
291
  };
287
292
 
293
+ GraphQLNonNull.prototype.toJSON = function toJSON() {
294
+ return this.toString();
295
+ };
296
+
288
297
  Object.defineProperty(GraphQLNonNull.prototype, SYMBOL_TO_STRING_TAG, {
289
298
  get: function get() {
290
299
  return 'GraphQLNonNull';
291
300
  }
292
- });
293
- defineToJSON(GraphQLNonNull);
301
+ }); // Print a simplified form when appearing in `inspect` and `util.inspect`.
302
+
303
+ defineInspect(GraphQLNonNull);
294
304
  /**
295
305
  * These types wrap and modify other types
296
306
  */
@@ -401,6 +411,7 @@ export var GraphQLScalarType = /*#__PURE__*/function () {
401
411
  var parseValue = (_config$parseValue = config.parseValue) !== null && _config$parseValue !== void 0 ? _config$parseValue : identityFunc;
402
412
  this.name = config.name;
403
413
  this.description = config.description;
414
+ this.specifiedByUrl = config.specifiedByUrl;
404
415
  this.serialize = (_config$serialize = config.serialize) !== null && _config$serialize !== void 0 ? _config$serialize : identityFunc;
405
416
  this.parseValue = parseValue;
406
417
  this.parseLiteral = (_config$parseLiteral = config.parseLiteral) !== null && _config$parseLiteral !== void 0 ? _config$parseLiteral : function (node) {
@@ -410,6 +421,7 @@ export var GraphQLScalarType = /*#__PURE__*/function () {
410
421
  this.astNode = config.astNode;
411
422
  this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
412
423
  typeof config.name === 'string' || devAssert(0, 'Must provide name.');
424
+ config.specifiedByUrl == null || typeof config.specifiedByUrl === 'string' || devAssert(0, "".concat(this.name, " must provide \"specifiedByUrl\" as a string, ") + "but got: ".concat(inspect(config.specifiedByUrl), "."));
413
425
  config.serialize == null || typeof config.serialize === 'function' || devAssert(0, "".concat(this.name, " must provide \"serialize\" function. If this custom Scalar is also used as an input type, ensure \"parseValue\" and \"parseLiteral\" functions are also provided."));
414
426
 
415
427
  if (config.parseLiteral) {
@@ -425,6 +437,7 @@ export var GraphQLScalarType = /*#__PURE__*/function () {
425
437
  return {
426
438
  name: this.name,
427
439
  description: this.description,
440
+ specifiedByUrl: this.specifiedByUrl,
428
441
  serialize: this.serialize,
429
442
  parseValue: this.parseValue,
430
443
  parseLiteral: this.parseLiteral,
@@ -436,6 +449,10 @@ export var GraphQLScalarType = /*#__PURE__*/function () {
436
449
 
437
450
  _proto.toString = function toString() {
438
451
  return this.name;
452
+ };
453
+
454
+ _proto.toJSON = function toJSON() {
455
+ return this.toString();
439
456
  } // $FlowFixMe Flow doesn't support computed properties yet
440
457
  ;
441
458
 
@@ -447,8 +464,9 @@ export var GraphQLScalarType = /*#__PURE__*/function () {
447
464
  }]);
448
465
 
449
466
  return GraphQLScalarType;
450
- }();
451
- defineToJSON(GraphQLScalarType);
467
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
468
+
469
+ defineInspect(GraphQLScalarType);
452
470
 
453
471
  /**
454
472
  * Object Type Definition
@@ -534,6 +552,10 @@ export var GraphQLObjectType = /*#__PURE__*/function () {
534
552
 
535
553
  _proto2.toString = function toString() {
536
554
  return this.name;
555
+ };
556
+
557
+ _proto2.toJSON = function toJSON() {
558
+ return this.toString();
537
559
  } // $FlowFixMe Flow doesn't support computed properties yet
538
560
  ;
539
561
 
@@ -545,8 +567,9 @@ export var GraphQLObjectType = /*#__PURE__*/function () {
545
567
  }]);
546
568
 
547
569
  return GraphQLObjectType;
548
- }();
549
- defineToJSON(GraphQLObjectType);
570
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
571
+
572
+ defineInspect(GraphQLObjectType);
550
573
 
551
574
  function defineInterfaces(config) {
552
575
  var _resolveThunk;
@@ -701,6 +724,10 @@ export var GraphQLInterfaceType = /*#__PURE__*/function () {
701
724
 
702
725
  _proto3.toString = function toString() {
703
726
  return this.name;
727
+ };
728
+
729
+ _proto3.toJSON = function toJSON() {
730
+ return this.toString();
704
731
  } // $FlowFixMe Flow doesn't support computed properties yet
705
732
  ;
706
733
 
@@ -712,8 +739,9 @@ export var GraphQLInterfaceType = /*#__PURE__*/function () {
712
739
  }]);
713
740
 
714
741
  return GraphQLInterfaceType;
715
- }();
716
- defineToJSON(GraphQLInterfaceType);
742
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
743
+
744
+ defineInspect(GraphQLInterfaceType);
717
745
 
718
746
  /**
719
747
  * Union Type Definition
@@ -777,6 +805,10 @@ export var GraphQLUnionType = /*#__PURE__*/function () {
777
805
 
778
806
  _proto4.toString = function toString() {
779
807
  return this.name;
808
+ };
809
+
810
+ _proto4.toJSON = function toJSON() {
811
+ return this.toString();
780
812
  } // $FlowFixMe Flow doesn't support computed properties yet
781
813
  ;
782
814
 
@@ -788,8 +820,9 @@ export var GraphQLUnionType = /*#__PURE__*/function () {
788
820
  }]);
789
821
 
790
822
  return GraphQLUnionType;
791
- }();
792
- defineToJSON(GraphQLUnionType);
823
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
824
+
825
+ defineInspect(GraphQLUnionType);
793
826
 
794
827
  function defineTypes(config) {
795
828
  var types = resolveThunk(config.types);
@@ -920,6 +953,10 @@ export var GraphQLEnumType
920
953
 
921
954
  _proto5.toString = function toString() {
922
955
  return this.name;
956
+ };
957
+
958
+ _proto5.toJSON = function toJSON() {
959
+ return this.toString();
923
960
  } // $FlowFixMe Flow doesn't support computed properties yet
924
961
  ;
925
962
 
@@ -931,8 +968,9 @@ export var GraphQLEnumType
931
968
  }]);
932
969
 
933
970
  return GraphQLEnumType;
934
- }();
935
- defineToJSON(GraphQLEnumType);
971
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
972
+
973
+ defineInspect(GraphQLEnumType);
936
974
 
937
975
  function didYouMeanEnumValue(enumType, unknownValueStr) {
938
976
  var allNames = enumType.getValues().map(function (value) {
@@ -1026,6 +1064,10 @@ export var GraphQLInputObjectType = /*#__PURE__*/function () {
1026
1064
 
1027
1065
  _proto6.toString = function toString() {
1028
1066
  return this.name;
1067
+ };
1068
+
1069
+ _proto6.toJSON = function toJSON() {
1070
+ return this.toString();
1029
1071
  } // $FlowFixMe Flow doesn't support computed properties yet
1030
1072
  ;
1031
1073
 
@@ -1037,8 +1079,9 @@ export var GraphQLInputObjectType = /*#__PURE__*/function () {
1037
1079
  }]);
1038
1080
 
1039
1081
  return GraphQLInputObjectType;
1040
- }();
1041
- defineToJSON(GraphQLInputObjectType);
1082
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
1083
+
1084
+ defineInspect(GraphQLInputObjectType);
1042
1085
 
1043
1086
  function defineInputFieldMap(config) {
1044
1087
  var fieldMap = resolveThunk(config.fields);
@@ -1,7 +1,7 @@
1
1
  // FIXME
2
2
  /* eslint-disable import/no-cycle */
3
3
 
4
- import Maybe from '../tsutils/Maybe';
4
+ import { Maybe } from '../jsutils/Maybe';
5
5
 
6
6
  import { DirectiveDefinitionNode } from '../language/ast';
7
7
  import { DirectiveLocationEnum } from '../language/directiveLocation';
@@ -59,6 +59,11 @@ export const GraphQLIncludeDirective: GraphQLDirective;
59
59
  */
60
60
  export const GraphQLSkipDirective: GraphQLDirective;
61
61
 
62
+ /**
63
+ * Used to provide a URL for specifying the behavior of custom scalar definitions.
64
+ */
65
+ export const GraphQLSpecifiedByDirective: GraphQLDirective;
66
+
62
67
  /**
63
68
  * Constant string used for default reason for a deprecation.
64
69
  */
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isDirective = isDirective;
7
7
  exports.assertDirective = assertDirective;
8
8
  exports.isSpecifiedDirective = isSpecifiedDirective;
9
- exports.specifiedDirectives = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = void 0;
9
+ exports.specifiedDirectives = exports.GraphQLSpecifiedByDirective = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = void 0;
10
10
 
11
11
  var _objectEntries = _interopRequireDefault(require("../polyfills/objectEntries"));
12
12
 
@@ -20,10 +20,10 @@ var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
20
20
 
21
21
  var _instanceOf = _interopRequireDefault(require("../jsutils/instanceOf"));
22
22
 
23
- var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
24
-
25
23
  var _isObjectLike = _interopRequireDefault(require("../jsutils/isObjectLike"));
26
24
 
25
+ var _defineInspect = _interopRequireDefault(require("../jsutils/defineInspect"));
26
+
27
27
  var _directiveLocation = require("../language/directiveLocation");
28
28
 
29
29
  var _scalars = require("./scalars");
@@ -98,6 +98,10 @@ var GraphQLDirective = /*#__PURE__*/function () {
98
98
 
99
99
  _proto.toString = function toString() {
100
100
  return '@' + this.name;
101
+ };
102
+
103
+ _proto.toJSON = function toJSON() {
104
+ return this.toString();
101
105
  } // $FlowFixMe Flow doesn't support computed properties yet
102
106
  ;
103
107
 
@@ -109,10 +113,11 @@ var GraphQLDirective = /*#__PURE__*/function () {
109
113
  }]);
110
114
 
111
115
  return GraphQLDirective;
112
- }();
116
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
117
+
113
118
 
114
119
  exports.GraphQLDirective = GraphQLDirective;
115
- (0, _defineToJSON.default)(GraphQLDirective);
120
+ (0, _defineInspect.default)(GraphQLDirective);
116
121
 
117
122
  /**
118
123
  * Used to conditionally include fields or fragments.
@@ -168,11 +173,27 @@ var GraphQLDeprecatedDirective = new GraphQLDirective({
168
173
  }
169
174
  });
170
175
  /**
171
- * The full list of specified directives.
176
+ * Used to provide a URL for specifying the behaviour of custom scalar definitions.
172
177
  */
173
178
 
174
179
  exports.GraphQLDeprecatedDirective = GraphQLDeprecatedDirective;
175
- var specifiedDirectives = Object.freeze([GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective]);
180
+ var GraphQLSpecifiedByDirective = new GraphQLDirective({
181
+ name: 'specifiedBy',
182
+ description: 'Exposes a URL that specifies the behaviour of this scalar.',
183
+ locations: [_directiveLocation.DirectiveLocation.SCALAR],
184
+ args: {
185
+ url: {
186
+ type: (0, _definition.GraphQLNonNull)(_scalars.GraphQLString),
187
+ description: 'The URL that specifies the behaviour of this scalar.'
188
+ }
189
+ }
190
+ });
191
+ /**
192
+ * The full list of specified directives.
193
+ */
194
+
195
+ exports.GraphQLSpecifiedByDirective = GraphQLSpecifiedByDirective;
196
+ var specifiedDirectives = Object.freeze([GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective]);
176
197
  exports.specifiedDirectives = specifiedDirectives;
177
198
 
178
199
  function isSpecifiedDirective(directive) {
@@ -7,8 +7,8 @@ import inspect from '../jsutils/inspect';
7
7
  import toObjMap from '../jsutils/toObjMap';
8
8
  import devAssert from '../jsutils/devAssert';
9
9
  import instanceOf from '../jsutils/instanceOf';
10
- import defineToJSON from '../jsutils/defineToJSON';
11
10
  import isObjectLike from '../jsutils/isObjectLike';
11
+ import defineInspect from '../jsutils/defineInspect';
12
12
  import {
13
13
  type ReadOnlyObjMap,
14
14
  type ReadOnlyObjMapLike,
@@ -112,13 +112,18 @@ export class GraphQLDirective {
112
112
  return '@' + this.name;
113
113
  }
114
114
 
115
+ toJSON(): string {
116
+ return this.toString();
117
+ }
118
+
115
119
  // $FlowFixMe Flow doesn't support computed properties yet
116
120
  get [SYMBOL_TO_STRING_TAG]() {
117
121
  return 'GraphQLDirective';
118
122
  }
119
123
  }
120
124
 
121
- defineToJSON(GraphQLDirective);
125
+ // Print a simplified form when appearing in `inspect` and `util.inspect`.
126
+ defineInspect(GraphQLDirective);
122
127
 
123
128
  export type GraphQLDirectiveConfig = {|
124
129
  name: string,
@@ -192,6 +197,21 @@ export const GraphQLDeprecatedDirective = new GraphQLDirective({
192
197
  },
193
198
  });
194
199
 
200
+ /**
201
+ * Used to provide a URL for specifying the behaviour of custom scalar definitions.
202
+ */
203
+ export const GraphQLSpecifiedByDirective = new GraphQLDirective({
204
+ name: 'specifiedBy',
205
+ description: 'Exposes a URL that specifies the behaviour of this scalar.',
206
+ locations: [DirectiveLocation.SCALAR],
207
+ args: {
208
+ url: {
209
+ type: GraphQLNonNull(GraphQLString),
210
+ description: 'The URL that specifies the behaviour of this scalar.',
211
+ },
212
+ },
213
+ });
214
+
195
215
  /**
196
216
  * The full list of specified directives.
197
217
  */
@@ -199,6 +219,7 @@ export const specifiedDirectives = Object.freeze([
199
219
  GraphQLIncludeDirective,
200
220
  GraphQLSkipDirective,
201
221
  GraphQLDeprecatedDirective,
222
+ GraphQLSpecifiedByDirective,
202
223
  ]);
203
224
 
204
225
  export function isSpecifiedDirective(
@@ -8,8 +8,8 @@ import inspect from "../jsutils/inspect.mjs";
8
8
  import toObjMap from "../jsutils/toObjMap.mjs";
9
9
  import devAssert from "../jsutils/devAssert.mjs";
10
10
  import instanceOf from "../jsutils/instanceOf.mjs";
11
- import defineToJSON from "../jsutils/defineToJSON.mjs";
12
11
  import isObjectLike from "../jsutils/isObjectLike.mjs";
12
+ import defineInspect from "../jsutils/defineInspect.mjs";
13
13
  import { DirectiveLocation } from "../language/directiveLocation.mjs";
14
14
  import { GraphQLString, GraphQLBoolean } from "./scalars.mjs";
15
15
  import { argsToArgsConfig, GraphQLNonNull } from "./definition.mjs";
@@ -77,6 +77,10 @@ export var GraphQLDirective = /*#__PURE__*/function () {
77
77
 
78
78
  _proto.toString = function toString() {
79
79
  return '@' + this.name;
80
+ };
81
+
82
+ _proto.toJSON = function toJSON() {
83
+ return this.toString();
80
84
  } // $FlowFixMe Flow doesn't support computed properties yet
81
85
  ;
82
86
 
@@ -88,8 +92,9 @@ export var GraphQLDirective = /*#__PURE__*/function () {
88
92
  }]);
89
93
 
90
94
  return GraphQLDirective;
91
- }();
92
- defineToJSON(GraphQLDirective);
95
+ }(); // Print a simplified form when appearing in `inspect` and `util.inspect`.
96
+
97
+ defineInspect(GraphQLDirective);
93
98
 
94
99
  /**
95
100
  * Used to conditionally include fields or fragments.
@@ -141,11 +146,26 @@ export var GraphQLDeprecatedDirective = new GraphQLDirective({
141
146
  }
142
147
  }
143
148
  });
149
+ /**
150
+ * Used to provide a URL for specifying the behaviour of custom scalar definitions.
151
+ */
152
+
153
+ export var GraphQLSpecifiedByDirective = new GraphQLDirective({
154
+ name: 'specifiedBy',
155
+ description: 'Exposes a URL that specifies the behaviour of this scalar.',
156
+ locations: [DirectiveLocation.SCALAR],
157
+ args: {
158
+ url: {
159
+ type: GraphQLNonNull(GraphQLString),
160
+ description: 'The URL that specifies the behaviour of this scalar.'
161
+ }
162
+ }
163
+ });
144
164
  /**
145
165
  * The full list of specified directives.
146
166
  */
147
167
 
148
- export var specifiedDirectives = Object.freeze([GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective]);
168
+ export var specifiedDirectives = Object.freeze([GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective]);
149
169
  export function isSpecifiedDirective(directive) {
150
170
  return specifiedDirectives.some(function (_ref2) {
151
171
  var name = _ref2.name;
package/type/index.d.ts CHANGED
@@ -115,6 +115,7 @@ export {
115
115
  GraphQLIncludeDirective,
116
116
  GraphQLSkipDirective,
117
117
  GraphQLDeprecatedDirective,
118
+ GraphQLSpecifiedByDirective,
118
119
  // Constant Deprecation Reason
119
120
  DEFAULT_DEPRECATION_REASON,
120
121
  // type
package/type/index.js CHANGED
@@ -345,6 +345,12 @@ Object.defineProperty(exports, "GraphQLDeprecatedDirective", {
345
345
  return _directives.GraphQLDeprecatedDirective;
346
346
  }
347
347
  });
348
+ Object.defineProperty(exports, "GraphQLSpecifiedByDirective", {
349
+ enumerable: true,
350
+ get: function get() {
351
+ return _directives.GraphQLSpecifiedByDirective;
352
+ }
353
+ });
348
354
  Object.defineProperty(exports, "DEFAULT_DEPRECATION_REASON", {
349
355
  enumerable: true,
350
356
  get: function get() {
@@ -79,6 +79,7 @@ export {
79
79
  GraphQLIncludeDirective,
80
80
  GraphQLSkipDirective,
81
81
  GraphQLDeprecatedDirective,
82
+ GraphQLSpecifiedByDirective,
82
83
  // Constant Deprecation Reason
83
84
  DEFAULT_DEPRECATION_REASON,
84
85
  } from './directives';
package/type/index.mjs CHANGED
@@ -12,7 +12,7 @@ export { // Predicate
12
12
  isDirective // Assertion
13
13
  , assertDirective // Directives Definition
14
14
  , GraphQLDirective // Built-in Directives defined by the Spec
15
- , isSpecifiedDirective, specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective // Constant Deprecation Reason
15
+ , isSpecifiedDirective, specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective // Constant Deprecation Reason
16
16
  , DEFAULT_DEPRECATION_REASON } from "./directives.mjs";
17
17
  // Common built-in scalar instances.
18
18
  export { // Predicate
@@ -207,7 +207,7 @@ exports.__DirectiveLocation = __DirectiveLocation;
207
207
 
208
208
  var __Type = new _definition.GraphQLObjectType({
209
209
  name: '__Type',
210
- description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',
210
+ description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',
211
211
  fields: function fields() {
212
212
  return {
213
213
  kind: {
@@ -239,16 +239,15 @@ var __Type = new _definition.GraphQLObjectType({
239
239
 
240
240
  if ((0, _definition.isListType)(type)) {
241
241
  return TypeKind.LIST;
242
- }
242
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
243
+
243
244
 
244
- /* istanbul ignore else */
245
245
  if ((0, _definition.isNonNullType)(type)) {
246
246
  return TypeKind.NON_NULL;
247
- } // Not reachable. All possible types have been considered.
247
+ } // istanbul ignore next (Not reachable. All possible types have been considered)
248
248
 
249
249
 
250
- /* istanbul ignore next */
251
- (0, _invariant.default)(false, "Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
250
+ false || (0, _invariant.default)(0, "Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
252
251
  }
253
252
  },
254
253
  name: {
@@ -263,6 +262,12 @@ var __Type = new _definition.GraphQLObjectType({
263
262
  return type.description !== undefined ? type.description : undefined;
264
263
  }
265
264
  },
265
+ specifiedByUrl: {
266
+ type: _scalars.GraphQLString,
267
+ resolve: function resolve(obj) {
268
+ return obj.specifiedByUrl !== undefined ? obj.specifiedByUrl : undefined;
269
+ }
270
+ },
266
271
  fields: {
267
272
  type: (0, _definition.GraphQLList)((0, _definition.GraphQLNonNull)(__Field)),
268
273
  args: {
@@ -195,7 +195,7 @@ export const __DirectiveLocation = new GraphQLEnumType({
195
195
  export const __Type = new GraphQLObjectType({
196
196
  name: '__Type',
197
197
  description:
198
- 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',
198
+ 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',
199
199
  fields: () =>
200
200
  ({
201
201
  kind: {
@@ -222,11 +222,12 @@ export const __Type = new GraphQLObjectType({
222
222
  if (isListType(type)) {
223
223
  return TypeKind.LIST;
224
224
  }
225
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
225
226
  if (isNonNullType(type)) {
226
227
  return TypeKind.NON_NULL;
227
228
  }
228
229
 
229
- // Not reachable. All possible types have been considered.
230
+ // istanbul ignore next (Not reachable. All possible types have been considered)
230
231
  invariant(false, `Unexpected type: "${inspect((type: empty))}".`);
231
232
  },
232
233
  },
@@ -239,6 +240,11 @@ export const __Type = new GraphQLObjectType({
239
240
  resolve: (type) =>
240
241
  type.description !== undefined ? type.description : undefined,
241
242
  },
243
+ specifiedByUrl: {
244
+ type: GraphQLString,
245
+ resolve: (obj) =>
246
+ obj.specifiedByUrl !== undefined ? obj.specifiedByUrl : undefined,
247
+ },
242
248
  fields: {
243
249
  type: GraphQLList(GraphQLNonNull(__Field)),
244
250
  args: {
@@ -180,7 +180,7 @@ export var __DirectiveLocation = new GraphQLEnumType({
180
180
  });
181
181
  export var __Type = new GraphQLObjectType({
182
182
  name: '__Type',
183
- description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',
183
+ description: 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.',
184
184
  fields: function fields() {
185
185
  return {
186
186
  kind: {
@@ -212,16 +212,15 @@ export var __Type = new GraphQLObjectType({
212
212
 
213
213
  if (isListType(type)) {
214
214
  return TypeKind.LIST;
215
- }
215
+ } // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
216
+
216
217
 
217
- /* istanbul ignore else */
218
218
  if (isNonNullType(type)) {
219
219
  return TypeKind.NON_NULL;
220
- } // Not reachable. All possible types have been considered.
220
+ } // istanbul ignore next (Not reachable. All possible types have been considered)
221
221
 
222
222
 
223
- /* istanbul ignore next */
224
- invariant(false, "Unexpected type: \"".concat(inspect(type), "\"."));
223
+ false || invariant(0, "Unexpected type: \"".concat(inspect(type), "\"."));
225
224
  }
226
225
  },
227
226
  name: {
@@ -236,6 +235,12 @@ export var __Type = new GraphQLObjectType({
236
235
  return type.description !== undefined ? type.description : undefined;
237
236
  }
238
237
  },
238
+ specifiedByUrl: {
239
+ type: GraphQLString,
240
+ resolve: function resolve(obj) {
241
+ return obj.specifiedByUrl !== undefined ? obj.specifiedByUrl : undefined;
242
+ }
243
+ },
239
244
  fields: {
240
245
  type: GraphQLList(GraphQLNonNull(__Field)),
241
246
  args: {
package/type/schema.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // FIXME
2
2
  /* eslint-disable import/no-cycle */
3
3
 
4
- import Maybe from '../tsutils/Maybe';
4
+ import { Maybe } from '../jsutils/Maybe';
5
5
 
6
6
  import { SchemaDefinitionNode, SchemaExtensionNode } from '../language/ast';
7
7
 
@@ -89,12 +89,14 @@ export class GraphQLSchema {
89
89
  };
90
90
  }
91
91
 
92
- type TypeMap = { [key: string]: GraphQLNamedType };
92
+ interface TypeMap {
93
+ [key: string]: GraphQLNamedType;
94
+ }
93
95
 
94
- type InterfaceImplementations = {
96
+ interface InterfaceImplementations {
95
97
  objects: ReadonlyArray<GraphQLObjectType>;
96
98
  interfaces: ReadonlyArray<GraphQLInterfaceType>;
97
- };
99
+ }
98
100
 
99
101
  export interface GraphQLSchemaValidationOptions {
100
102
  /**
@@ -109,7 +111,7 @@ export interface GraphQLSchemaValidationOptions {
109
111
 
110
112
  export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
111
113
  description?: Maybe<string>;
112
- query: Maybe<GraphQLObjectType>;
114
+ query?: Maybe<GraphQLObjectType>;
113
115
  mutation?: Maybe<GraphQLObjectType>;
114
116
  subscription?: Maybe<GraphQLObjectType>;
115
117
  types?: Maybe<Array<GraphQLNamedType>>;