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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.
4
4
 
5
5
  [![npm version](https://badge.fury.io/js/graphql.svg)](https://badge.fury.io/js/graphql)
6
- [![Build Status](https://travis-ci.org/graphql/graphql-js.svg?branch=master)](https://travis-ci.org/graphql/graphql-js?branch=master)
6
+ [![Build Status](https://github.com/graphql/graphql-js/workflows/CI/badge.svg?branch=master)](https://github.com/graphql/graphql-js/actions?query=branch%3Amaster)
7
7
  [![Coverage Status](https://codecov.io/gh/graphql/graphql-js/branch/master/graph/badge.svg)](https://codecov.io/gh/graphql/graphql-js)
8
8
 
9
9
  See more complete documentation at https://graphql.org/ and
@@ -24,16 +24,16 @@ through that README and the corresponding tests in parallel.
24
24
 
25
25
  Install GraphQL.js from npm
26
26
 
27
- With yarn:
27
+ With npm:
28
28
 
29
29
  ```sh
30
- yarn add graphql
30
+ npm install --save graphql
31
31
  ```
32
32
 
33
- or alternatively using npm:
33
+ or alternatively using yarn:
34
34
 
35
35
  ```sh
36
- npm install --save graphql
36
+ yarn add graphql
37
37
  ```
38
38
 
39
39
  GraphQL.js provides two important capabilities: building a type schema, and
@@ -1,4 +1,4 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
2
 
3
3
  import { ASTNode } from '../language/ast';
4
4
  import { Source } from '../language/source';
@@ -13,7 +13,7 @@ import { SourceLocation } from '../language/location';
13
13
  export class GraphQLError extends Error {
14
14
  constructor(
15
15
  message: string,
16
- nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
16
+ nodes?: Maybe<ReadonlyArray<ASTNode> | ASTNode>,
17
17
  source?: Maybe<Source>,
18
18
  positions?: Maybe<ReadonlyArray<number>>,
19
19
  path?: Maybe<ReadonlyArray<string | number>>,
@@ -24,14 +24,14 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
24
24
 
25
25
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
26
26
 
27
- function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
27
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
28
+
29
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
28
30
 
29
31
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
30
32
 
31
33
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
34
 
33
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
34
-
35
35
  function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
36
36
 
37
37
  function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
@@ -226,8 +226,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
226
226
  configurable: true
227
227
  });
228
228
  return _possibleConstructorReturn(_this);
229
- }
230
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
229
+ } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
231
230
 
232
231
 
233
232
  if (Error.captureStackTrace) {
@@ -196,7 +196,7 @@ export class GraphQLError extends Error {
196
196
  return;
197
197
  }
198
198
 
199
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
199
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
200
200
  if (Error.captureStackTrace) {
201
201
  Error.captureStackTrace(this, GraphQLError);
202
202
  } else {
@@ -6,14 +6,14 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
6
6
 
7
7
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8
8
 
9
- function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
+
11
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
12
 
11
13
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12
14
 
13
15
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
16
 
15
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16
-
17
17
  function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
18
18
 
19
19
  function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
@@ -215,8 +215,7 @@ export var GraphQLError = /*#__PURE__*/function (_Error) {
215
215
  configurable: true
216
216
  });
217
217
  return _possibleConstructorReturn(_this);
218
- }
219
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
218
+ } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
220
219
 
221
220
 
222
221
  if (Error.captureStackTrace) {
@@ -1,4 +1,4 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
2
 
3
3
  import { ASTNode } from '../language/ast';
4
4
 
@@ -1,4 +1,5 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
+
2
3
  import { PromiseOrValue } from '../jsutils/PromiseOrValue';
3
4
  import { Path } from '../jsutils/Path';
4
5
 
@@ -43,12 +44,13 @@ export interface ExecutionContext {
43
44
  * - `errors` is included when any errors occurred as a non-empty array.
44
45
  * - `data` is the result of a successful execution of the query.
45
46
  */
46
- export interface ExecutionResult {
47
+ export interface ExecutionResult<TData = { [key: string]: any }> {
47
48
  errors?: ReadonlyArray<GraphQLError>;
48
- data?: { [key: string]: any } | null;
49
+ // TS_SPECIFIC: TData. Motivation: https://github.com/graphql/graphql-js/pull/2490#issuecomment-639154229
50
+ data?: TData | null;
49
51
  }
50
52
 
51
- export type ExecutionArgs = {
53
+ export interface ExecutionArgs {
52
54
  schema: GraphQLSchema;
53
55
  document: DocumentNode;
54
56
  rootValue?: any;
@@ -57,7 +59,7 @@ export type ExecutionArgs = {
57
59
  operationName?: Maybe<string>;
58
60
  fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
59
61
  typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
60
- };
62
+ }
61
63
 
62
64
  /**
63
65
  * Implements the "Evaluating requests" section of the GraphQL specification.
@@ -147,7 +149,7 @@ export function resolveFieldValueOrError(
147
149
  resolveFn: GraphQLFieldResolver<any, any>,
148
150
  source: any,
149
151
  info: GraphQLResolveInfo,
150
- ): Error | any;
152
+ ): any;
151
153
 
152
154
  /**
153
155
  * If a resolveType function is not given, then a default resolve behavior is
@@ -182,8 +182,7 @@ function buildExecutionContext(schema, document, rootValue, contextValue, rawVar
182
182
  }
183
183
 
184
184
  return [new _GraphQLError.GraphQLError('Must provide an operation.')];
185
- }
186
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
185
+ } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
187
186
 
188
187
 
189
188
  var variableDefinitions = (_operation$variableDe = operation.variableDefinitions) !== null && _operation$variableDe !== void 0 ? _operation$variableDe : [];
@@ -603,16 +602,15 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
603
602
  if ((0, _definition.isAbstractType)(returnType)) {
604
603
  return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
605
604
  } // If field type is Object, execute and complete all sub-selections.
605
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
606
606
 
607
607
 
608
- /* istanbul ignore else */
609
608
  if ((0, _definition.isObjectType)(returnType)) {
610
609
  return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
611
- } // Not reachable. All possible output types have been considered.
610
+ } // istanbul ignore next (Not reachable. All possible output types have been considered)
612
611
 
613
612
 
614
- /* istanbul ignore next */
615
- (0, _invariant.default)(false, 'Cannot complete value of unexpected output type: ' + (0, _inspect.default)(returnType));
613
+ false || (0, _invariant.default)(0, 'Cannot complete value of unexpected output type: ' + (0, _inspect.default)(returnType));
616
614
  }
617
615
  /**
618
616
  * Complete a list value by completing each item in the list with the
@@ -311,7 +311,7 @@ export function buildExecutionContext(
311
311
  return [new GraphQLError('Must provide an operation.')];
312
312
  }
313
313
 
314
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
314
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
315
315
  const variableDefinitions = operation.variableDefinitions ?? [];
316
316
 
317
317
  const coercedVariableValues = getVariableValues(
@@ -868,6 +868,7 @@ function completeValue(
868
868
  }
869
869
 
870
870
  // If field type is Object, execute and complete all sub-selections.
871
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
871
872
  if (isObjectType(returnType)) {
872
873
  return completeObjectValue(
873
874
  exeContext,
@@ -879,7 +880,7 @@ function completeValue(
879
880
  );
880
881
  }
881
882
 
882
- // Not reachable. All possible output types have been considered.
883
+ // istanbul ignore next (Not reachable. All possible output types have been considered)
883
884
  invariant(
884
885
  false,
885
886
  'Cannot complete value of unexpected output type: ' +
@@ -171,8 +171,7 @@ export function buildExecutionContext(schema, document, rootValue, contextValue,
171
171
  }
172
172
 
173
173
  return [new GraphQLError('Must provide an operation.')];
174
- }
175
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
174
+ } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
176
175
 
177
176
 
178
177
  var variableDefinitions = (_operation$variableDe = operation.variableDefinitions) !== null && _operation$variableDe !== void 0 ? _operation$variableDe : [];
@@ -588,16 +587,15 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
588
587
  if (isAbstractType(returnType)) {
589
588
  return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
590
589
  } // If field type is Object, execute and complete all sub-selections.
590
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
591
591
 
592
592
 
593
- /* istanbul ignore else */
594
593
  if (isObjectType(returnType)) {
595
594
  return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
596
- } // Not reachable. All possible output types have been considered.
595
+ } // istanbul ignore next (Not reachable. All possible output types have been considered)
597
596
 
598
597
 
599
- /* istanbul ignore next */
600
- invariant(false, 'Cannot complete value of unexpected output type: ' + inspect(returnType));
598
+ false || invariant(0, 'Cannot complete value of unexpected output type: ' + inspect(returnType));
601
599
  }
602
600
  /**
603
601
  * Complete a list value by completing each item in the list with the
@@ -1,4 +1,5 @@
1
- import Maybe from '../tsutils/Maybe';
1
+ import { Maybe } from '../jsutils/Maybe';
2
+
2
3
  import { GraphQLError } from '../error/GraphQLError';
3
4
  import {
4
5
  FieldNode,
@@ -140,8 +140,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
140
140
  function getArgumentValues(def, node, variableValues) {
141
141
  var _node$arguments;
142
142
 
143
- var coercedValues = {};
144
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
143
+ var coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
145
144
 
146
145
  var argumentNodes = (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 ? _node$arguments : [];
147
146
  var argNodeMap = (0, _keyMap.default)(argumentNodes, function (arg) {
@@ -170,7 +170,7 @@ export function getArgumentValues(
170
170
  ): { [argument: string]: mixed, ... } {
171
171
  const coercedValues = {};
172
172
 
173
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
173
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
174
174
  const argumentNodes = node.arguments ?? [];
175
175
  const argNodeMap = keyMap(argumentNodes, (arg) => arg.name.value);
176
176
 
@@ -119,8 +119,7 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
119
119
  export function getArgumentValues(def, node, variableValues) {
120
120
  var _node$arguments;
121
121
 
122
- var coercedValues = {};
123
- /* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
122
+ var coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
124
123
 
125
124
  var argumentNodes = (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 ? _node$arguments : [];
126
125
  var argNodeMap = keyMap(argumentNodes, function (arg) {
package/graphql.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import Maybe from './tsutils/Maybe';
1
+ import { Maybe } from './jsutils/Maybe';
2
+
2
3
  import { Source } from './language/source';
3
4
  import { GraphQLSchema } from './type/schema';
4
5
  import { GraphQLFieldResolver, GraphQLTypeResolver } from './type/definition';
package/index.d.ts CHANGED
@@ -55,6 +55,7 @@ export {
55
55
  GraphQLIncludeDirective,
56
56
  GraphQLSkipDirective,
57
57
  GraphQLDeprecatedDirective,
58
+ GraphQLSpecifiedByDirective,
58
59
  // "Enum" of Type Kinds
59
60
  TypeKind,
60
61
  // Constant Deprecation Reason
@@ -171,7 +172,9 @@ export {
171
172
 
172
173
  // Parse and operate on GraphQL language source files.
173
174
  export {
175
+ Token,
174
176
  Source,
177
+ Location,
175
178
  getLocation,
176
179
  // Print source location
177
180
  printLocation,
@@ -207,8 +210,6 @@ export {
207
210
  export {
208
211
  ParseOptions,
209
212
  SourceLocation,
210
- Location,
211
- Token,
212
213
  TokenKindEnum,
213
214
  KindEnum,
214
215
  DirectiveLocationEnum,
package/index.js CHANGED
@@ -147,6 +147,12 @@ Object.defineProperty(exports, "GraphQLDeprecatedDirective", {
147
147
  return _index.GraphQLDeprecatedDirective;
148
148
  }
149
149
  });
150
+ Object.defineProperty(exports, "GraphQLSpecifiedByDirective", {
151
+ enumerable: true,
152
+ get: function get() {
153
+ return _index.GraphQLSpecifiedByDirective;
154
+ }
155
+ });
150
156
  Object.defineProperty(exports, "TypeKind", {
151
157
  enumerable: true,
152
158
  get: function get() {
@@ -513,12 +519,24 @@ Object.defineProperty(exports, "assertValidSchema", {
513
519
  return _index.assertValidSchema;
514
520
  }
515
521
  });
522
+ Object.defineProperty(exports, "Token", {
523
+ enumerable: true,
524
+ get: function get() {
525
+ return _index2.Token;
526
+ }
527
+ });
516
528
  Object.defineProperty(exports, "Source", {
517
529
  enumerable: true,
518
530
  get: function get() {
519
531
  return _index2.Source;
520
532
  }
521
533
  });
534
+ Object.defineProperty(exports, "Location", {
535
+ enumerable: true,
536
+ get: function get() {
537
+ return _index2.Location;
538
+ }
539
+ });
522
540
  Object.defineProperty(exports, "getLocation", {
523
541
  enumerable: true,
524
542
  get: function get() {
package/index.js.flow CHANGED
@@ -56,6 +56,7 @@ export {
56
56
  GraphQLIncludeDirective,
57
57
  GraphQLSkipDirective,
58
58
  GraphQLDeprecatedDirective,
59
+ GraphQLSpecifiedByDirective,
59
60
  // "Enum" of Type Kinds
60
61
  TypeKind,
61
62
  // Constant Deprecation Reason
@@ -172,7 +173,9 @@ export type {
172
173
 
173
174
  // Parse and operate on GraphQL language source files.
174
175
  export {
176
+ Token,
175
177
  Source,
178
+ Location,
176
179
  getLocation,
177
180
  // Print source location
178
181
  printLocation,
@@ -208,8 +211,6 @@ export {
208
211
  export type {
209
212
  ParseOptions,
210
213
  SourceLocation,
211
- Location,
212
- Token,
213
214
  TokenKindEnum,
214
215
  KindEnum,
215
216
  DirectiveLocationEnum,
package/index.mjs CHANGED
@@ -29,7 +29,7 @@ export { graphql, graphqlSync } from "./graphql.mjs"; // Create and operate on G
29
29
  export { // Definitions
30
30
  GraphQLSchema, GraphQLDirective, GraphQLScalarType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLEnumType, GraphQLInputObjectType, GraphQLList, GraphQLNonNull // Standard GraphQL Scalars
31
31
  , specifiedScalarTypes, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean, GraphQLID // Built-in Directives defined by the Spec
32
- , specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective // "Enum" of Type Kinds
32
+ , specifiedDirectives, GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective, GraphQLSpecifiedByDirective // "Enum" of Type Kinds
33
33
  , TypeKind // Constant Deprecation Reason
34
34
  , DEFAULT_DEPRECATION_REASON // GraphQL Types for introspection.
35
35
  , introspectionTypes, __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue, __EnumValue, __TypeKind // Meta-field definitions.
@@ -39,7 +39,7 @@ GraphQLSchema, GraphQLDirective, GraphQLScalarType, GraphQLObjectType, GraphQLIn
39
39
  , getNullableType, getNamedType // Validate GraphQL schema.
40
40
  , validateSchema, assertValidSchema } from "./type/index.mjs";
41
41
  // Parse and operate on GraphQL language source files.
42
- export { Source, getLocation // Print source location
42
+ export { Token, Source, Location, getLocation // Print source location
43
43
  , printLocation, printSourceLocation // Lex
44
44
  , Lexer, TokenKind // Parse
45
45
  , parse, parseValue, parseType // Print
@@ -0,0 +1,2 @@
1
+ // Conveniently represents flow's "Maybe" type https://flow.org/en/docs/types/maybe/
2
+ export type Maybe<T> = null | undefined | T;
package/jsutils/Path.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export type Path = {
1
+ export interface Path {
2
2
  prev: Path | undefined;
3
3
  key: string | number;
4
- };
4
+ }
5
5
 
6
6
  /**
7
7
  * Given a Path and a key, return a new Path containing the new key.
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = defineInspect;
7
+
8
+ var _invariant = _interopRequireDefault(require("./invariant"));
9
+
10
+ var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ /**
15
+ * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
16
+ */
17
+ function defineInspect(classObject) {
18
+ var fn = classObject.prototype.toJSON;
19
+ typeof fn === 'function' || (0, _invariant.default)(0);
20
+ classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
21
+
22
+ if (_nodejsCustomInspectSymbol.default) {
23
+ classObject.prototype[_nodejsCustomInspectSymbol.default] = fn;
24
+ }
25
+ }
@@ -0,0 +1,21 @@
1
+ // @flow strict
2
+
3
+ import invariant from './invariant';
4
+ import nodejsCustomInspectSymbol from './nodejsCustomInspectSymbol';
5
+
6
+ /**
7
+ * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
8
+ */
9
+ export default function defineInspect(
10
+ classObject: Class<any> | ((...args: Array<any>) => mixed),
11
+ ): void {
12
+ const fn = classObject.prototype.toJSON;
13
+ invariant(typeof fn === 'function');
14
+
15
+ classObject.prototype.inspect = fn;
16
+
17
+ // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
18
+ if (nodejsCustomInspectSymbol) {
19
+ classObject.prototype[nodejsCustomInspectSymbol] = fn;
20
+ }
21
+ }
@@ -0,0 +1,15 @@
1
+ import invariant from "./invariant.mjs";
2
+ import nodejsCustomInspectSymbol from "./nodejsCustomInspectSymbol.mjs";
3
+ /**
4
+ * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
5
+ */
6
+
7
+ export default function defineInspect(classObject) {
8
+ var fn = classObject.prototype.toJSON;
9
+ typeof fn === 'function' || invariant(0);
10
+ classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
11
+
12
+ if (nodejsCustomInspectSymbol) {
13
+ classObject.prototype[nodejsCustomInspectSymbol] = fn;
14
+ }
15
+ }
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = devAssert;
7
7
 
8
8
  function devAssert(condition, message) {
9
- var booleanCondition = Boolean(condition);
10
- /* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
9
+ var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
11
10
 
12
11
  if (!booleanCondition) {
13
12
  throw new Error(message);
@@ -2,7 +2,7 @@
2
2
 
3
3
  export default function devAssert(condition: mixed, message: string): void {
4
4
  const booleanCondition = Boolean(condition);
5
- /* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
5
+ // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
6
6
  if (!booleanCondition) {
7
7
  throw new Error(message);
8
8
  }
@@ -1,6 +1,5 @@
1
1
  export default function devAssert(condition, message) {
2
- var booleanCondition = Boolean(condition);
3
- /* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
2
+ var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
4
3
 
5
4
  if (!booleanCondition) {
6
5
  throw new Error(message);
@@ -11,8 +11,7 @@ exports.default = void 0;
11
11
  */
12
12
  // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
13
13
  // See: https://webpack.js.org/guides/production/
14
- var _default = process.env.NODE_ENV === 'production' ?
15
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
14
+ var _default = process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
16
15
  // eslint-disable-next-line no-shadow
17
16
  function instanceOf(value, constructor) {
18
17
  return value instanceof constructor;
@@ -12,7 +12,7 @@ declare function instanceOf(
12
12
  // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
13
13
  // See: https://webpack.js.org/guides/production/
14
14
  export default process.env.NODE_ENV === 'production'
15
- ? /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
15
+ ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
16
16
  // eslint-disable-next-line no-shadow
17
17
  function instanceOf(value: mixed, constructor: mixed) {
18
18
  return value instanceof constructor;
@@ -4,8 +4,7 @@
4
4
  */
5
5
  // See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
6
6
  // See: https://webpack.js.org/guides/production/
7
- export default process.env.NODE_ENV === 'production' ?
8
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
7
+ export default process.env.NODE_ENV === 'production' ? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
9
8
  // eslint-disable-next-line no-shadow
10
9
  function instanceOf(value, constructor) {
11
10
  return value instanceof constructor;
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = invariant;
7
7
 
8
8
  function invariant(condition, message) {
9
- var booleanCondition = Boolean(condition);
10
- /* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
9
+ var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
11
10
 
12
11
  if (!booleanCondition) {
13
12
  throw new Error(message != null ? message : 'Unexpected invariant triggered.');
@@ -2,7 +2,7 @@
2
2
 
3
3
  export default function invariant(condition: mixed, message?: string): void {
4
4
  const booleanCondition = Boolean(condition);
5
- /* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
5
+ // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
6
6
  if (!booleanCondition) {
7
7
  throw new Error(
8
8
  message != null ? message : 'Unexpected invariant triggered.',
@@ -1,6 +1,5 @@
1
1
  export default function invariant(condition, message) {
2
- var booleanCondition = Boolean(condition);
3
- /* istanbul ignore else (see transformation done in './resources/inlineInvariant.js') */
2
+ var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
4
3
 
5
4
  if (!booleanCondition) {
6
5
  throw new Error(message != null ? message : 'Unexpected invariant triggered.');
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
7
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
9
8
  var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
10
9
  var _default = nodejsCustomInspectSymbol;
11
10
  exports.default = _default;
@@ -1,6 +1,6 @@
1
1
  // @flow strict
2
2
 
3
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
3
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
4
4
  const nodejsCustomInspectSymbol =
5
5
  typeof Symbol === 'function' && typeof Symbol.for === 'function'
6
6
  ? Symbol.for('nodejs.util.inspect.custom')
@@ -1,3 +1,3 @@
1
- /* istanbul ignore next (See: https://github.com/graphql/graphql-js/issues/2317) */
1
+ // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
2
2
  var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
3
3
  export default nodejsCustomInspectSymbol;