graphql 16.0.1 → 16.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 (112) hide show
  1. package/README.md +4 -4
  2. package/error/GraphQLError.js +4 -1
  3. package/error/GraphQLError.mjs +4 -1
  4. package/error/locatedError.js +2 -8
  5. package/error/locatedError.mjs +2 -6
  6. package/execution/execute.js +16 -5
  7. package/execution/execute.mjs +16 -5
  8. package/execution/mapAsyncIterator.js +3 -1
  9. package/execution/mapAsyncIterator.mjs +3 -1
  10. package/execution/subscribe.js +8 -0
  11. package/execution/subscribe.mjs +7 -0
  12. package/execution/values.js +3 -2
  13. package/execution/values.mjs +3 -2
  14. package/graphql.js +8 -0
  15. package/graphql.mjs +7 -0
  16. package/index.d.ts +3 -0
  17. package/index.js +12 -0
  18. package/index.mjs +3 -0
  19. package/jsutils/devAssert.js +1 -1
  20. package/jsutils/devAssert.mjs +1 -1
  21. package/jsutils/instanceOf.js +3 -1
  22. package/jsutils/instanceOf.mjs +3 -1
  23. package/jsutils/invariant.js +1 -1
  24. package/jsutils/invariant.mjs +1 -1
  25. package/jsutils/mapValue.js +2 -2
  26. package/jsutils/mapValue.mjs +2 -2
  27. package/jsutils/toError.d.ts +4 -0
  28. package/jsutils/toError.js +25 -0
  29. package/jsutils/toError.mjs +18 -0
  30. package/language/blockString.d.ts +7 -3
  31. package/language/blockString.js +121 -64
  32. package/language/blockString.mjs +111 -62
  33. package/language/characterClasses.d.ts +9 -0
  34. package/language/characterClasses.js +13 -0
  35. package/language/characterClasses.mjs +12 -0
  36. package/language/lexer.js +21 -13
  37. package/language/lexer.mjs +22 -14
  38. package/language/parser.js +3 -2
  39. package/language/parser.mjs +3 -2
  40. package/language/printer.js +3 -1
  41. package/language/printer.mjs +3 -1
  42. package/language/visitor.js +2 -1
  43. package/language/visitor.mjs +2 -1
  44. package/package.json +4 -1
  45. package/type/directives.d.ts +1 -1
  46. package/type/directives.js +3 -3
  47. package/type/directives.mjs +3 -3
  48. package/type/index.d.ts +3 -0
  49. package/type/index.js +12 -0
  50. package/type/index.mjs +3 -0
  51. package/type/introspection.js +8 -4
  52. package/type/introspection.mjs +8 -4
  53. package/type/scalars.d.ts +10 -0
  54. package/type/scalars.js +18 -10
  55. package/type/scalars.mjs +16 -11
  56. package/type/schema.d.ts +1 -1
  57. package/type/schema.js +5 -3
  58. package/type/schema.mjs +4 -3
  59. package/type/validate.js +35 -26
  60. package/type/validate.mjs +35 -26
  61. package/utilities/TypeInfo.js +4 -0
  62. package/utilities/TypeInfo.mjs +4 -0
  63. package/utilities/assertValidName.js +3 -2
  64. package/utilities/assertValidName.mjs +3 -2
  65. package/utilities/astFromValue.js +4 -2
  66. package/utilities/astFromValue.mjs +4 -2
  67. package/utilities/buildClientSchema.js +2 -0
  68. package/utilities/buildClientSchema.mjs +2 -0
  69. package/utilities/coerceInputValue.js +4 -2
  70. package/utilities/coerceInputValue.mjs +4 -2
  71. package/utilities/extendSchema.js +40 -32
  72. package/utilities/extendSchema.mjs +40 -29
  73. package/utilities/findBreakingChanges.js +4 -2
  74. package/utilities/findBreakingChanges.mjs +4 -2
  75. package/utilities/lexicographicSortSchema.js +6 -5
  76. package/utilities/lexicographicSortSchema.mjs +6 -5
  77. package/utilities/printSchema.js +9 -7
  78. package/utilities/printSchema.mjs +10 -5
  79. package/utilities/separateOperations.js +2 -0
  80. package/utilities/separateOperations.mjs +2 -0
  81. package/utilities/stripIgnoredCharacters.js +3 -19
  82. package/utilities/stripIgnoredCharacters.mjs +4 -23
  83. package/utilities/typeFromAST.js +13 -24
  84. package/utilities/typeFromAST.mjs +12 -17
  85. package/utilities/valueFromAST.js +4 -2
  86. package/utilities/valueFromAST.mjs +4 -2
  87. package/utilities/valueFromASTUntyped.js +1 -11
  88. package/utilities/valueFromASTUntyped.mjs +1 -5
  89. package/validation/rules/KnownArgumentNamesRule.js +3 -1
  90. package/validation/rules/KnownArgumentNamesRule.mjs +3 -1
  91. package/validation/rules/KnownDirectivesRule.js +11 -7
  92. package/validation/rules/KnownDirectivesRule.mjs +7 -3
  93. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +4 -3
  94. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +4 -3
  95. package/validation/rules/PossibleTypeExtensionsRule.js +14 -8
  96. package/validation/rules/PossibleTypeExtensionsRule.mjs +10 -4
  97. package/validation/rules/ProvidedRequiredArgumentsRule.js +8 -3
  98. package/validation/rules/ProvidedRequiredArgumentsRule.mjs +8 -3
  99. package/validation/rules/UniqueArgumentDefinitionNamesRule.js +9 -3
  100. package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +9 -3
  101. package/validation/rules/UniqueArgumentNamesRule.js +3 -1
  102. package/validation/rules/UniqueArgumentNamesRule.mjs +3 -1
  103. package/validation/rules/UniqueEnumValueNamesRule.js +3 -1
  104. package/validation/rules/UniqueEnumValueNamesRule.mjs +3 -1
  105. package/validation/rules/UniqueFieldDefinitionNamesRule.js +3 -1
  106. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +3 -1
  107. package/validation/rules/UniqueOperationTypesRule.js +3 -1
  108. package/validation/rules/UniqueOperationTypesRule.mjs +3 -1
  109. package/validation/rules/UniqueVariableNamesRule.js +3 -1
  110. package/validation/rules/UniqueVariableNamesRule.mjs +3 -1
  111. package/version.js +3 -3
  112. package/version.mjs +3 -3
package/README.md CHANGED
@@ -71,9 +71,9 @@ or an array of promises. A more complex example is included in the top-level [te
71
71
  Then, serve the result of a query against that type schema.
72
72
 
73
73
  ```js
74
- var query = '{ hello }';
74
+ var source = '{ hello }';
75
75
 
76
- graphql(schema, query).then((result) => {
76
+ graphql({ schema, source }).then((result) => {
77
77
  // Prints
78
78
  // {
79
79
  // data: { hello: "world" }
@@ -87,9 +87,9 @@ first ensure the query is syntactically and semantically valid before executing
87
87
  it, reporting errors otherwise.
88
88
 
89
89
  ```js
90
- var query = '{ BoyHowdy }';
90
+ var source = '{ BoyHowdy }';
91
91
 
92
- graphql(schema, query).then((result) => {
92
+ graphql({ schema, source }).then((result) => {
93
93
  // Prints
94
94
  // {
95
95
  // errors: [
@@ -151,7 +151,9 @@ class GraphQLError extends Error {
151
151
  enumerable: false,
152
152
  },
153
153
  }); // Include (non-enumerable) stack trace.
154
- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
154
+
155
+ /* c8 ignore start */
156
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
155
157
 
156
158
  if (
157
159
  originalError !== null &&
@@ -172,6 +174,7 @@ class GraphQLError extends Error {
172
174
  configurable: true,
173
175
  });
174
176
  }
177
+ /* c8 ignore stop */
175
178
  }
176
179
 
177
180
  get [Symbol.toStringTag]() {
@@ -150,7 +150,9 @@ export class GraphQLError extends Error {
150
150
  enumerable: false,
151
151
  },
152
152
  }); // Include (non-enumerable) stack trace.
153
- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
153
+
154
+ /* c8 ignore start */
155
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
154
156
 
155
157
  if (
156
158
  originalError !== null &&
@@ -171,6 +173,7 @@ export class GraphQLError extends Error {
171
173
  configurable: true,
172
174
  });
173
175
  }
176
+ /* c8 ignore stop */
174
177
  }
175
178
 
176
179
  get [Symbol.toStringTag]() {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', {
5
5
  });
6
6
  exports.locatedError = locatedError;
7
7
 
8
- var _inspect = require('../jsutils/inspect.js');
8
+ var _toError = require('../jsutils/toError.js');
9
9
 
10
10
  var _GraphQLError = require('./GraphQLError.js');
11
11
 
@@ -17,13 +17,7 @@ var _GraphQLError = require('./GraphQLError.js');
17
17
  function locatedError(rawOriginalError, nodes, path) {
18
18
  var _nodes;
19
19
 
20
- // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
21
- const originalError =
22
- rawOriginalError instanceof Error
23
- ? rawOriginalError
24
- : new Error(
25
- 'Unexpected error value: ' + (0, _inspect.inspect)(rawOriginalError),
26
- ); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
20
+ const originalError = (0, _toError.toError)(rawOriginalError); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
27
21
 
28
22
  if (isLocatedGraphQLError(originalError)) {
29
23
  return originalError;
@@ -1,4 +1,4 @@
1
- import { inspect } from '../jsutils/inspect.mjs';
1
+ import { toError } from '../jsutils/toError.mjs';
2
2
  import { GraphQLError } from './GraphQLError.mjs';
3
3
  /**
4
4
  * Given an arbitrary value, presumably thrown while attempting to execute a
@@ -9,11 +9,7 @@ import { GraphQLError } from './GraphQLError.mjs';
9
9
  export function locatedError(rawOriginalError, nodes, path) {
10
10
  var _nodes;
11
11
 
12
- // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
13
- const originalError =
14
- rawOriginalError instanceof Error
15
- ? rawOriginalError
16
- : new Error('Unexpected error value: ' + inspect(rawOriginalError)); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
12
+ const originalError = toError(rawOriginalError); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
17
13
 
18
14
  if (isLocatedGraphQLError(originalError)) {
19
15
  return originalError;
@@ -102,6 +102,12 @@ const collectSubfields = (0, _memoize.memoize3)(
102
102
  * a GraphQLError will be thrown immediately explaining the invalid input.
103
103
  */
104
104
  function execute(args) {
105
+ // Temporary for v15 to v16 migration. Remove in v17
106
+ arguments.length < 2 ||
107
+ (0, _devAssert.devAssert)(
108
+ false,
109
+ 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.',
110
+ );
105
111
  const { schema, document, variableValues, rootValue } = args; // If arguments are missing or incorrect, throw an error.
106
112
 
107
113
  assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
@@ -247,6 +253,8 @@ function buildExecutionContext(args) {
247
253
  case _kinds.Kind.FRAGMENT_DEFINITION:
248
254
  fragments[definition.name.value] = definition;
249
255
  break;
256
+
257
+ default: // ignore non-executable definitions
250
258
  }
251
259
  }
252
260
 
@@ -260,7 +268,9 @@ function buildExecutionContext(args) {
260
268
  }
261
269
 
262
270
  return [new _GraphQLError.GraphQLError('Must provide an operation.')];
263
- } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
271
+ } // FIXME: https://github.com/graphql/graphql-js/issues/2203
272
+
273
+ /* c8 ignore next */
264
274
 
265
275
  const variableDefinitions =
266
276
  (_operation$variableDe = operation.variableDefinitions) !== null &&
@@ -424,7 +434,7 @@ function executeFields(exeContext, parentType, sourceValue, path, fields) {
424
434
  return (0, _promiseForObject.promiseForObject)(results);
425
435
  }
426
436
  /**
427
- * Implements the "Executing field" section of the spec
437
+ * Implements the "Executing fields" section of the spec
428
438
  * In particular, this function figures out the value that the field returns by
429
439
  * calling its resolve function, then calls completeValue to complete promises,
430
440
  * serialize scalars, or execute the sub-selection-set for objects.
@@ -541,7 +551,7 @@ function handleFieldError(error, returnType, exeContext) {
541
551
  }
542
552
  /**
543
553
  * Implements the instructions for completeValue as defined in the
544
- * "Field entries" section of the spec.
554
+ * "Value Completion" section of the spec.
545
555
  *
546
556
  * If the field type is Non-Null, then this recursively completes the value
547
557
  * for the inner type. It throws a field error if that completion returns null,
@@ -618,7 +628,6 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
618
628
  result,
619
629
  );
620
630
  } // If field type is Object, execute and complete all sub-selections.
621
- // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
622
631
 
623
632
  if ((0, _definition.isObjectType)(returnType)) {
624
633
  return completeObjectValue(
@@ -629,7 +638,9 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
629
638
  path,
630
639
  result,
631
640
  );
632
- } // istanbul ignore next (Not reachable. All possible output types have been considered)
641
+ }
642
+ /* c8 ignore next 6 */
643
+ // Not reachable, all possible output types have been considered.
633
644
 
634
645
  false ||
635
646
  (0, _invariant.invariant)(
@@ -83,6 +83,12 @@ const collectSubfields = memoize3((exeContext, returnType, fieldNodes) =>
83
83
  * a GraphQLError will be thrown immediately explaining the invalid input.
84
84
  */
85
85
  export function execute(args) {
86
+ // Temporary for v15 to v16 migration. Remove in v17
87
+ arguments.length < 2 ||
88
+ devAssert(
89
+ false,
90
+ 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.',
91
+ );
86
92
  const { schema, document, variableValues, rootValue } = args; // If arguments are missing or incorrect, throw an error.
87
93
 
88
94
  assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments,
@@ -232,6 +238,8 @@ export function buildExecutionContext(args) {
232
238
  case Kind.FRAGMENT_DEFINITION:
233
239
  fragments[definition.name.value] = definition;
234
240
  break;
241
+
242
+ default: // ignore non-executable definitions
235
243
  }
236
244
  }
237
245
 
@@ -241,7 +249,9 @@ export function buildExecutionContext(args) {
241
249
  }
242
250
 
243
251
  return [new GraphQLError('Must provide an operation.')];
244
- } // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
252
+ } // FIXME: https://github.com/graphql/graphql-js/issues/2203
253
+
254
+ /* c8 ignore next */
245
255
 
246
256
  const variableDefinitions =
247
257
  (_operation$variableDe = operation.variableDefinitions) !== null &&
@@ -405,7 +415,7 @@ function executeFields(exeContext, parentType, sourceValue, path, fields) {
405
415
  return promiseForObject(results);
406
416
  }
407
417
  /**
408
- * Implements the "Executing field" section of the spec
418
+ * Implements the "Executing fields" section of the spec
409
419
  * In particular, this function figures out the value that the field returns by
410
420
  * calling its resolve function, then calls completeValue to complete promises,
411
421
  * serialize scalars, or execute the sub-selection-set for objects.
@@ -520,7 +530,7 @@ function handleFieldError(error, returnType, exeContext) {
520
530
  }
521
531
  /**
522
532
  * Implements the instructions for completeValue as defined in the
523
- * "Field entries" section of the spec.
533
+ * "Value Completion" section of the spec.
524
534
  *
525
535
  * If the field type is Non-Null, then this recursively completes the value
526
536
  * for the inner type. It throws a field error if that completion returns null,
@@ -597,7 +607,6 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
597
607
  result,
598
608
  );
599
609
  } // If field type is Object, execute and complete all sub-selections.
600
- // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
601
610
 
602
611
  if (isObjectType(returnType)) {
603
612
  return completeObjectValue(
@@ -608,7 +617,9 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
608
617
  path,
609
618
  result,
610
619
  );
611
- } // istanbul ignore next (Not reachable. All possible output types have been considered)
620
+ }
621
+ /* c8 ignore next 6 */
622
+ // Not reachable, all possible output types have been considered.
612
623
 
613
624
  false ||
614
625
  invariant(
@@ -23,7 +23,8 @@ function mapAsyncIterator(iterable, callback) {
23
23
  done: false,
24
24
  };
25
25
  } catch (error) {
26
- // istanbul ignore else (FIXME: add test case)
26
+ /* c8 ignore start */
27
+ // FIXME: add test case
27
28
  if (typeof iterator.return === 'function') {
28
29
  try {
29
30
  await iterator.return();
@@ -33,6 +34,7 @@ function mapAsyncIterator(iterable, callback) {
33
34
  }
34
35
 
35
36
  throw error;
37
+ /* c8 ignore stop */
36
38
  }
37
39
  }
38
40
 
@@ -16,7 +16,8 @@ export function mapAsyncIterator(iterable, callback) {
16
16
  done: false,
17
17
  };
18
18
  } catch (error) {
19
- // istanbul ignore else (FIXME: add test case)
19
+ /* c8 ignore start */
20
+ // FIXME: add test case
20
21
  if (typeof iterator.return === 'function') {
21
22
  try {
22
23
  await iterator.return();
@@ -26,6 +27,7 @@ export function mapAsyncIterator(iterable, callback) {
26
27
  }
27
28
 
28
29
  throw error;
30
+ /* c8 ignore stop */
29
31
  }
30
32
  }
31
33
 
@@ -8,6 +8,8 @@ exports.subscribe = subscribe;
8
8
 
9
9
  var _inspect = require('../jsutils/inspect.js');
10
10
 
11
+ var _devAssert = require('../jsutils/devAssert.js');
12
+
11
13
  var _isAsyncIterable = require('../jsutils/isAsyncIterable.js');
12
14
 
13
15
  var _Path = require('../jsutils/Path.js');
@@ -46,6 +48,12 @@ var _mapAsyncIterator = require('./mapAsyncIterator.js');
46
48
  * Accepts either an object with named arguments, or individual arguments.
47
49
  */
48
50
  async function subscribe(args) {
51
+ // Temporary for v15 to v16 migration. Remove in v17
52
+ arguments.length < 2 ||
53
+ (0, _devAssert.devAssert)(
54
+ false,
55
+ 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.',
56
+ );
49
57
  const {
50
58
  schema,
51
59
  document,
@@ -1,4 +1,5 @@
1
1
  import { inspect } from '../jsutils/inspect.mjs';
2
+ import { devAssert } from '../jsutils/devAssert.mjs';
2
3
  import { isAsyncIterable } from '../jsutils/isAsyncIterable.mjs';
3
4
  import { addPath, pathToArray } from '../jsutils/Path.mjs';
4
5
  import { GraphQLError } from '../error/GraphQLError.mjs';
@@ -36,6 +37,12 @@ import { mapAsyncIterator } from './mapAsyncIterator.mjs';
36
37
  */
37
38
 
38
39
  export async function subscribe(args) {
40
+ // Temporary for v15 to v16 migration. Remove in v17
41
+ arguments.length < 2 ||
42
+ devAssert(
43
+ false,
44
+ 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.',
45
+ );
39
46
  const {
40
47
  schema,
41
48
  document,
@@ -169,7 +169,9 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
169
169
  function getArgumentValues(def, node, variableValues) {
170
170
  var _node$arguments;
171
171
 
172
- const coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
172
+ const coercedValues = {}; // FIXME: https://github.com/graphql/graphql-js/issues/2203
173
+
174
+ /* c8 ignore next */
173
175
 
174
176
  const argumentNodes =
175
177
  (_node$arguments = node.arguments) !== null && _node$arguments !== void 0
@@ -275,7 +277,6 @@ function getArgumentValues(def, node, variableValues) {
275
277
  function getDirectiveValues(directiveDef, node, variableValues) {
276
278
  var _node$directives;
277
279
 
278
- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
279
280
  const directiveNode =
280
281
  (_node$directives = node.directives) === null || _node$directives === void 0
281
282
  ? void 0
@@ -145,7 +145,9 @@ function coerceVariableValues(schema, varDefNodes, inputs, onError) {
145
145
  export function getArgumentValues(def, node, variableValues) {
146
146
  var _node$arguments;
147
147
 
148
- const coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
148
+ const coercedValues = {}; // FIXME: https://github.com/graphql/graphql-js/issues/2203
149
+
150
+ /* c8 ignore next */
149
151
 
150
152
  const argumentNodes =
151
153
  (_node$arguments = node.arguments) !== null && _node$arguments !== void 0
@@ -238,7 +240,6 @@ export function getArgumentValues(def, node, variableValues) {
238
240
  export function getDirectiveValues(directiveDef, node, variableValues) {
239
241
  var _node$directives;
240
242
 
241
- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
242
243
  const directiveNode =
243
244
  (_node$directives = node.directives) === null || _node$directives === void 0
244
245
  ? void 0
package/graphql.js CHANGED
@@ -6,6 +6,8 @@ Object.defineProperty(exports, '__esModule', {
6
6
  exports.graphql = graphql;
7
7
  exports.graphqlSync = graphqlSync;
8
8
 
9
+ var _devAssert = require('./jsutils/devAssert.js');
10
+
9
11
  var _isPromise = require('./jsutils/isPromise.js');
10
12
 
11
13
  var _parser = require('./language/parser.js');
@@ -38,6 +40,12 @@ function graphqlSync(args) {
38
40
  }
39
41
 
40
42
  function graphqlImpl(args) {
43
+ // Temporary for v15 to v16 migration. Remove in v17
44
+ arguments.length < 2 ||
45
+ (0, _devAssert.devAssert)(
46
+ false,
47
+ 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.',
48
+ );
41
49
  const {
42
50
  schema,
43
51
  source,
package/graphql.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { devAssert } from './jsutils/devAssert.mjs';
1
2
  import { isPromise } from './jsutils/isPromise.mjs';
2
3
  import { parse } from './language/parser.mjs';
3
4
  import { validate } from './validation/validate.mjs';
@@ -65,6 +66,12 @@ export function graphqlSync(args) {
65
66
  }
66
67
 
67
68
  function graphqlImpl(args) {
69
+ // Temporary for v15 to v16 migration. Remove in v17
70
+ arguments.length < 2 ||
71
+ devAssert(
72
+ false,
73
+ 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.',
74
+ );
68
75
  const {
69
76
  schema,
70
77
  source,
package/index.d.ts CHANGED
@@ -48,6 +48,9 @@ export {
48
48
  GraphQLString,
49
49
  GraphQLBoolean,
50
50
  GraphQLID,
51
+ /** Int boundaries constants */
52
+ GRAPHQL_MAX_INT,
53
+ GRAPHQL_MIN_INT,
51
54
  /** Built-in Directives defined by the Spec */
52
55
  specifiedDirectives,
53
56
  GraphQLIncludeDirective,
package/index.js CHANGED
@@ -51,6 +51,18 @@ Object.defineProperty(exports, 'FragmentsOnCompositeTypesRule', {
51
51
  return _index4.FragmentsOnCompositeTypesRule;
52
52
  },
53
53
  });
54
+ Object.defineProperty(exports, 'GRAPHQL_MAX_INT', {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _index.GRAPHQL_MAX_INT;
58
+ },
59
+ });
60
+ Object.defineProperty(exports, 'GRAPHQL_MIN_INT', {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _index.GRAPHQL_MIN_INT;
64
+ },
65
+ });
54
66
  Object.defineProperty(exports, 'GraphQLBoolean', {
55
67
  enumerable: true,
56
68
  get: function () {
package/index.mjs CHANGED
@@ -50,6 +50,9 @@ export {
50
50
  GraphQLString,
51
51
  GraphQLBoolean,
52
52
  GraphQLID,
53
+ /** Int boundaries constants */
54
+ GRAPHQL_MAX_INT,
55
+ GRAPHQL_MIN_INT,
53
56
  /** Built-in Directives defined by the Spec */
54
57
  specifiedDirectives,
55
58
  GraphQLIncludeDirective,
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', {
6
6
  exports.devAssert = devAssert;
7
7
 
8
8
  function devAssert(condition, message) {
9
- const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
9
+ const booleanCondition = Boolean(condition);
10
10
 
11
11
  if (!booleanCondition) {
12
12
  throw new Error(message);
@@ -1,5 +1,5 @@
1
1
  export function devAssert(condition, message) {
2
- const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
2
+ const booleanCondition = Boolean(condition);
3
3
 
4
4
  if (!booleanCondition) {
5
5
  throw new Error(message);
@@ -14,7 +14,9 @@ var _inspect = require('./inspect.js');
14
14
  * See: https://webpack.js.org/guides/production/
15
15
  */
16
16
  const instanceOf =
17
- process.env.NODE_ENV === 'production' // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
17
+ /* c8 ignore next 5 */
18
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
19
+ process.env.NODE_ENV === 'production'
18
20
  ? function instanceOf(value, constructor) {
19
21
  return value instanceof constructor;
20
22
  }
@@ -7,7 +7,9 @@ import { inspect } from './inspect.mjs';
7
7
  */
8
8
 
9
9
  export const instanceOf =
10
- process.env.NODE_ENV === 'production' // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
10
+ /* c8 ignore next 5 */
11
+ // FIXME: https://github.com/graphql/graphql-js/issues/2317
12
+ process.env.NODE_ENV === 'production'
11
13
  ? function instanceOf(value, constructor) {
12
14
  return value instanceof constructor;
13
15
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', {
6
6
  exports.invariant = invariant;
7
7
 
8
8
  function invariant(condition, message) {
9
- const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
9
+ const booleanCondition = Boolean(condition);
10
10
 
11
11
  if (!booleanCondition) {
12
12
  throw new Error(
@@ -1,5 +1,5 @@
1
1
  export function invariant(condition, message) {
2
- const booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
2
+ const booleanCondition = Boolean(condition);
3
3
 
4
4
  if (!booleanCondition) {
5
5
  throw new Error(
@@ -12,8 +12,8 @@ exports.mapValue = mapValue;
12
12
  function mapValue(map, fn) {
13
13
  const result = Object.create(null);
14
14
 
15
- for (const [key, value] of Object.entries(map)) {
16
- result[key] = fn(value, key);
15
+ for (const key of Object.keys(map)) {
16
+ result[key] = fn(map[key], key);
17
17
  }
18
18
 
19
19
  return result;
@@ -5,8 +5,8 @@
5
5
  export function mapValue(map, fn) {
6
6
  const result = Object.create(null);
7
7
 
8
- for (const [key, value] of Object.entries(map)) {
9
- result[key] = fn(value, key);
8
+ for (const key of Object.keys(map)) {
9
+ result[key] = fn(map[key], key);
10
10
  }
11
11
 
12
12
  return result;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
3
+ */
4
+ export declare function toError(thrownValue: unknown): Error;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true,
5
+ });
6
+ exports.toError = toError;
7
+
8
+ var _inspect = require('./inspect.js');
9
+
10
+ /**
11
+ * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
12
+ */
13
+ function toError(thrownValue) {
14
+ return thrownValue instanceof Error
15
+ ? thrownValue
16
+ : new NonErrorThrown(thrownValue);
17
+ }
18
+
19
+ class NonErrorThrown extends Error {
20
+ constructor(thrownValue) {
21
+ super('Unexpected error value: ' + (0, _inspect.inspect)(thrownValue));
22
+ this.name = 'NonErrorThrown';
23
+ this.thrownValue = thrownValue;
24
+ }
25
+ }
@@ -0,0 +1,18 @@
1
+ import { inspect } from './inspect.mjs';
2
+ /**
3
+ * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface.
4
+ */
5
+
6
+ export function toError(thrownValue) {
7
+ return thrownValue instanceof Error
8
+ ? thrownValue
9
+ : new NonErrorThrown(thrownValue);
10
+ }
11
+
12
+ class NonErrorThrown extends Error {
13
+ constructor(thrownValue) {
14
+ super('Unexpected error value: ' + inspect(thrownValue));
15
+ this.name = 'NonErrorThrown';
16
+ this.thrownValue = thrownValue;
17
+ }
18
+ }
@@ -6,11 +6,13 @@
6
6
  *
7
7
  * @internal
8
8
  */
9
- export declare function dedentBlockStringValue(rawString: string): string;
9
+ export declare function dedentBlockStringLines(
10
+ lines: ReadonlyArray<string>,
11
+ ): Array<string>;
10
12
  /**
11
13
  * @internal
12
14
  */
13
- export declare function getBlockStringIndentation(value: string): number;
15
+ export declare function isPrintableAsBlockString(value: string): boolean;
14
16
  /**
15
17
  * Print a block string in the indented block form by adding a leading and
16
18
  * trailing blank line. However, if a block string starts with whitespace and is
@@ -20,5 +22,7 @@ export declare function getBlockStringIndentation(value: string): number;
20
22
  */
21
23
  export declare function printBlockString(
22
24
  value: string,
23
- preferMultipleLines?: boolean,
25
+ options?: {
26
+ minimize?: boolean;
27
+ },
24
28
  ): string;