graphql 16.0.1 → 16.3.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 (177) hide show
  1. package/README.md +4 -4
  2. package/error/GraphQLError.d.ts +17 -1
  3. package/error/GraphQLError.js +28 -10
  4. package/error/GraphQLError.mjs +28 -19
  5. package/error/locatedError.js +2 -8
  6. package/error/locatedError.mjs +2 -6
  7. package/execution/collectFields.d.ts +8 -8
  8. package/execution/collectFields.js +8 -8
  9. package/execution/collectFields.mjs +7 -7
  10. package/execution/execute.d.ts +5 -5
  11. package/execution/execute.js +28 -17
  12. package/execution/execute.mjs +30 -19
  13. package/execution/index.d.ts +1 -1
  14. package/execution/index.js +6 -0
  15. package/execution/index.mjs +1 -1
  16. package/execution/mapAsyncIterator.js +3 -1
  17. package/execution/mapAsyncIterator.mjs +3 -1
  18. package/execution/subscribe.d.ts +1 -1
  19. package/execution/subscribe.js +10 -2
  20. package/execution/subscribe.mjs +8 -1
  21. package/execution/values.d.ts +3 -5
  22. package/execution/values.js +7 -8
  23. package/execution/values.mjs +5 -6
  24. package/graphql.js +12 -4
  25. package/graphql.mjs +8 -1
  26. package/index.d.ts +7 -61
  27. package/index.js +30 -0
  28. package/index.mjs +62 -111
  29. package/jsutils/devAssert.js +1 -1
  30. package/jsutils/devAssert.mjs +1 -1
  31. package/jsutils/instanceOf.js +3 -1
  32. package/jsutils/instanceOf.mjs +3 -1
  33. package/jsutils/invariant.js +1 -1
  34. package/jsutils/invariant.mjs +1 -1
  35. package/jsutils/mapValue.js +2 -2
  36. package/jsutils/mapValue.mjs +2 -2
  37. package/jsutils/promiseReduce.mjs +1 -1
  38. package/jsutils/toError.d.ts +4 -0
  39. package/jsutils/toError.js +25 -0
  40. package/jsutils/toError.mjs +18 -0
  41. package/language/blockString.d.ts +7 -3
  42. package/language/blockString.js +121 -64
  43. package/language/blockString.mjs +111 -62
  44. package/language/characterClasses.d.ts +9 -0
  45. package/language/characterClasses.js +13 -0
  46. package/language/characterClasses.mjs +12 -0
  47. package/language/index.d.ts +0 -1
  48. package/language/lexer.d.ts +1 -1
  49. package/language/lexer.js +23 -15
  50. package/language/lexer.mjs +23 -15
  51. package/language/parser.d.ts +40 -40
  52. package/language/parser.js +9 -8
  53. package/language/parser.mjs +7 -6
  54. package/language/predicates.d.ts +4 -4
  55. package/language/printLocation.d.ts +1 -1
  56. package/language/printLocation.mjs +1 -1
  57. package/language/printer.js +5 -3
  58. package/language/printer.mjs +4 -2
  59. package/language/source.js +2 -2
  60. package/language/source.mjs +1 -1
  61. package/language/visitor.js +12 -13
  62. package/language/visitor.mjs +11 -12
  63. package/package.json +4 -1
  64. package/type/assertName.mjs +1 -1
  65. package/type/definition.d.ts +18 -14
  66. package/type/definition.js +13 -11
  67. package/type/definition.mjs +10 -16
  68. package/type/directives.d.ts +1 -1
  69. package/type/directives.js +9 -9
  70. package/type/directives.mjs +7 -7
  71. package/type/index.d.ts +5 -27
  72. package/type/index.js +24 -0
  73. package/type/index.mjs +26 -40
  74. package/type/introspection.d.ts +2 -2
  75. package/type/introspection.js +12 -8
  76. package/type/introspection.mjs +16 -12
  77. package/type/scalars.d.ts +10 -0
  78. package/type/scalars.js +20 -12
  79. package/type/scalars.mjs +17 -12
  80. package/type/schema.d.ts +4 -4
  81. package/type/schema.js +11 -9
  82. package/type/schema.mjs +11 -10
  83. package/type/validate.js +39 -30
  84. package/type/validate.mjs +42 -33
  85. package/utilities/TypeInfo.d.ts +9 -9
  86. package/utilities/TypeInfo.js +6 -2
  87. package/utilities/TypeInfo.mjs +11 -7
  88. package/utilities/assertValidName.js +3 -2
  89. package/utilities/assertValidName.mjs +3 -2
  90. package/utilities/astFromValue.js +8 -6
  91. package/utilities/astFromValue.mjs +7 -5
  92. package/utilities/buildASTSchema.d.ts +1 -1
  93. package/utilities/buildASTSchema.js +2 -2
  94. package/utilities/buildASTSchema.mjs +2 -2
  95. package/utilities/buildClientSchema.js +9 -7
  96. package/utilities/buildClientSchema.mjs +17 -15
  97. package/utilities/coerceInputValue.js +9 -7
  98. package/utilities/coerceInputValue.mjs +9 -7
  99. package/utilities/extendSchema.d.ts +1 -1
  100. package/utilities/extendSchema.js +50 -42
  101. package/utilities/extendSchema.mjs +71 -60
  102. package/utilities/findBreakingChanges.js +9 -22
  103. package/utilities/findBreakingChanges.mjs +13 -22
  104. package/utilities/getIntrospectionQuery.d.ts +4 -0
  105. package/utilities/getIntrospectionQuery.js +4 -0
  106. package/utilities/getIntrospectionQuery.mjs +4 -0
  107. package/utilities/getOperationRootType.d.ts +1 -1
  108. package/utilities/index.d.ts +0 -25
  109. package/utilities/index.mjs +21 -44
  110. package/utilities/introspectionFromSchema.d.ts +1 -1
  111. package/utilities/lexicographicSortSchema.js +8 -7
  112. package/utilities/lexicographicSortSchema.mjs +16 -15
  113. package/utilities/printSchema.d.ts +1 -1
  114. package/utilities/printSchema.js +14 -12
  115. package/utilities/printSchema.mjs +20 -15
  116. package/utilities/separateOperations.js +2 -0
  117. package/utilities/separateOperations.mjs +2 -0
  118. package/utilities/sortValueNode.d.ts +9 -0
  119. package/utilities/sortValueNode.js +47 -0
  120. package/utilities/sortValueNode.mjs +39 -0
  121. package/utilities/stripIgnoredCharacters.js +7 -23
  122. package/utilities/stripIgnoredCharacters.mjs +6 -25
  123. package/utilities/typeComparators.d.ts +1 -1
  124. package/utilities/typeComparators.mjs +3 -3
  125. package/utilities/typeFromAST.d.ts +4 -4
  126. package/utilities/typeFromAST.js +13 -24
  127. package/utilities/typeFromAST.mjs +12 -25
  128. package/utilities/valueFromAST.d.ts +1 -1
  129. package/utilities/valueFromAST.js +6 -4
  130. package/utilities/valueFromAST.mjs +7 -5
  131. package/utilities/valueFromASTUntyped.d.ts +1 -1
  132. package/utilities/valueFromASTUntyped.js +1 -11
  133. package/utilities/valueFromASTUntyped.mjs +2 -6
  134. package/validation/ValidationContext.d.ts +10 -10
  135. package/validation/index.d.ts +0 -29
  136. package/validation/index.mjs +29 -58
  137. package/validation/rules/FieldsOnCorrectTypeRule.js +2 -2
  138. package/validation/rules/FieldsOnCorrectTypeRule.mjs +3 -3
  139. package/validation/rules/KnownArgumentNamesRule.d.ts +1 -1
  140. package/validation/rules/KnownArgumentNamesRule.js +3 -1
  141. package/validation/rules/KnownArgumentNamesRule.mjs +3 -1
  142. package/validation/rules/KnownDirectivesRule.d.ts +1 -1
  143. package/validation/rules/KnownDirectivesRule.js +13 -9
  144. package/validation/rules/KnownDirectivesRule.mjs +8 -4
  145. package/validation/rules/KnownTypeNamesRule.d.ts +1 -1
  146. package/validation/rules/KnownTypeNamesRule.js +2 -2
  147. package/validation/rules/KnownTypeNamesRule.mjs +1 -1
  148. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +41 -36
  149. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +41 -39
  150. package/validation/rules/PossibleFragmentSpreadsRule.js +2 -2
  151. package/validation/rules/PossibleFragmentSpreadsRule.mjs +1 -1
  152. package/validation/rules/PossibleTypeExtensionsRule.js +16 -10
  153. package/validation/rules/PossibleTypeExtensionsRule.mjs +15 -9
  154. package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +1 -1
  155. package/validation/rules/ProvidedRequiredArgumentsRule.js +10 -5
  156. package/validation/rules/ProvidedRequiredArgumentsRule.mjs +9 -4
  157. package/validation/rules/UniqueArgumentDefinitionNamesRule.js +9 -3
  158. package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +9 -3
  159. package/validation/rules/UniqueArgumentNamesRule.js +3 -1
  160. package/validation/rules/UniqueArgumentNamesRule.mjs +3 -1
  161. package/validation/rules/UniqueEnumValueNamesRule.js +3 -1
  162. package/validation/rules/UniqueEnumValueNamesRule.mjs +3 -1
  163. package/validation/rules/UniqueFieldDefinitionNamesRule.js +3 -1
  164. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +5 -3
  165. package/validation/rules/UniqueOperationTypesRule.js +3 -1
  166. package/validation/rules/UniqueOperationTypesRule.mjs +3 -1
  167. package/validation/rules/UniqueVariableNamesRule.js +3 -1
  168. package/validation/rules/UniqueVariableNamesRule.mjs +3 -1
  169. package/validation/rules/ValuesOfCorrectTypeRule.js +2 -2
  170. package/validation/rules/ValuesOfCorrectTypeRule.mjs +5 -5
  171. package/validation/rules/VariablesInAllowedPositionRule.js +2 -2
  172. package/validation/rules/VariablesInAllowedPositionRule.mjs +1 -1
  173. package/validation/specifiedRules.d.ts +1 -1
  174. package/validation/specifiedRules.js +47 -47
  175. package/validation/specifiedRules.mjs +41 -41
  176. package/version.js +3 -3
  177. package/version.mjs +3 -3
package/index.mjs CHANGED
@@ -22,17 +22,17 @@
22
22
  * import { parse } from 'graphql';
23
23
  * import { parse } from 'graphql/language';
24
24
  * ```
25
+ *
26
+ * @packageDocumentation
25
27
  */
28
+ // The GraphQL.js version info.
29
+ export { version, versionInfo } from './version.mjs'; // The primary entry point into fulfilling a GraphQL request.
26
30
 
27
- /** The GraphQL.js version info. */
28
- export { version, versionInfo } from './version.mjs';
29
- /** The primary entry point into fulfilling a GraphQL request. */
30
-
31
- export { graphql, graphqlSync } from './graphql.mjs';
32
- /** Create and operate on GraphQL type definitions and schema. */
31
+ export { graphql, graphqlSync } from './graphql.mjs'; // Create and operate on GraphQL type definitions and schema.
33
32
 
34
33
  export {
35
- /** Definitions */
34
+ resolveObjMapThunk,
35
+ resolveReadonlyArrayThunk, // Definitions
36
36
  GraphQLSchema,
37
37
  GraphQLDirective,
38
38
  GraphQLScalarType,
@@ -42,25 +42,22 @@ export {
42
42
  GraphQLEnumType,
43
43
  GraphQLInputObjectType,
44
44
  GraphQLList,
45
- GraphQLNonNull,
46
- /** Standard GraphQL Scalars */
45
+ GraphQLNonNull, // Standard GraphQL Scalars
47
46
  specifiedScalarTypes,
48
47
  GraphQLInt,
49
48
  GraphQLFloat,
50
49
  GraphQLString,
51
50
  GraphQLBoolean,
52
- GraphQLID,
53
- /** Built-in Directives defined by the Spec */
51
+ GraphQLID, // Int boundaries constants
52
+ GRAPHQL_MAX_INT,
53
+ GRAPHQL_MIN_INT, // Built-in Directives defined by the Spec
54
54
  specifiedDirectives,
55
55
  GraphQLIncludeDirective,
56
56
  GraphQLSkipDirective,
57
57
  GraphQLDeprecatedDirective,
58
- GraphQLSpecifiedByDirective,
59
- /** "Enum" of Type Kinds */
60
- TypeKind,
61
- /** Constant Deprecation Reason */
62
- DEFAULT_DEPRECATION_REASON,
63
- /** GraphQL Types for introspection. */
58
+ GraphQLSpecifiedByDirective, // "Enum" of Type Kinds
59
+ TypeKind, // Constant Deprecation Reason
60
+ DEFAULT_DEPRECATION_REASON, // GraphQL Types for introspection.
64
61
  introspectionTypes,
65
62
  __Schema,
66
63
  __Directive,
@@ -69,12 +66,10 @@ export {
69
66
  __Field,
70
67
  __InputValue,
71
68
  __EnumValue,
72
- __TypeKind,
73
- /** Meta-field definitions. */
69
+ __TypeKind, // Meta-field definitions.
74
70
  SchemaMetaFieldDef,
75
71
  TypeMetaFieldDef,
76
- TypeNameMetaFieldDef,
77
- /** Predicates */
72
+ TypeNameMetaFieldDef, // Predicates
78
73
  isSchema,
79
74
  isDirective,
80
75
  isType,
@@ -98,8 +93,7 @@ export {
98
93
  isRequiredInputField,
99
94
  isSpecifiedScalarType,
100
95
  isIntrospectionType,
101
- isSpecifiedDirective,
102
- /** Assertions */
96
+ isSpecifiedDirective, // Assertions
103
97
  assertSchema,
104
98
  assertDirective,
105
99
  assertType,
@@ -118,47 +112,37 @@ export {
118
112
  assertAbstractType,
119
113
  assertWrappingType,
120
114
  assertNullableType,
121
- assertNamedType,
122
- /** Un-modifiers */
115
+ assertNamedType, // Un-modifiers
123
116
  getNullableType,
124
- getNamedType,
125
- /** Validate GraphQL schema. */
117
+ getNamedType, // Validate GraphQL schema.
126
118
  validateSchema,
127
- assertValidSchema,
128
- /** Upholds the spec rules about naming. */
119
+ assertValidSchema, // Upholds the spec rules about naming.
129
120
  assertName,
130
121
  assertEnumValueName,
131
122
  } from './type/index.mjs';
132
-
133
- /** Parse and operate on GraphQL language source files. */
123
+ // Parse and operate on GraphQL language source files.
134
124
  export {
135
125
  Token,
136
126
  Source,
137
127
  Location,
138
128
  OperationTypeNode,
139
- getLocation,
140
- /** Print source location */
129
+ getLocation, // Print source location.
141
130
  printLocation,
142
- printSourceLocation,
143
- /** Lex */
131
+ printSourceLocation, // Lex
144
132
  Lexer,
145
- TokenKind,
146
- /** Parse */
133
+ TokenKind, // Parse
147
134
  parse,
148
135
  parseValue,
149
136
  parseConstValue,
150
- parseType,
151
- /** Print */
152
- print,
153
- /** Visit */
137
+ parseType, // Print
138
+ print, // Visit
154
139
  visit,
155
140
  visitInParallel,
156
141
  getVisitFn,
157
142
  getEnterLeaveForKind,
158
143
  BREAK,
159
144
  Kind,
160
- DirectiveLocation,
161
- /** Predicates */
145
+ DirectiveLocation, // Predicates
162
146
  isDefinitionNode,
163
147
  isExecutableDefinitionNode,
164
148
  isSelectionNode,
@@ -170,26 +154,23 @@ export {
170
154
  isTypeSystemExtensionNode,
171
155
  isTypeExtensionNode,
172
156
  } from './language/index.mjs';
173
-
174
- /** Execute GraphQL queries. */
157
+ // Execute GraphQL queries.
175
158
  export {
176
159
  execute,
177
160
  executeSync,
178
161
  defaultFieldResolver,
179
162
  defaultTypeResolver,
180
163
  responsePathAsArray,
164
+ getVariableValues,
181
165
  getDirectiveValues,
182
166
  subscribe,
183
167
  createSourceEventStream,
184
168
  } from './execution/index.mjs';
185
-
186
- /** Validate GraphQL documents. */
169
+ // Validate GraphQL documents.
187
170
  export {
188
171
  validate,
189
- ValidationContext,
190
- /** All validation rules in the GraphQL Specification. */
191
- specifiedRules,
192
- /** Individual validation rules. */
172
+ ValidationContext, // All validation rules in the GraphQL Specification.
173
+ specifiedRules, // Individual validation rules.
193
174
  ExecutableDefinitionsRule,
194
175
  FieldsOnCorrectTypeRule,
195
176
  FragmentsOnCompositeTypesRule,
@@ -215,8 +196,7 @@ export {
215
196
  UniqueVariableNamesRule,
216
197
  ValuesOfCorrectTypeRule,
217
198
  VariablesAreInputTypesRule,
218
- VariablesInAllowedPositionRule,
219
- /** SDL-specific validation rules */
199
+ VariablesInAllowedPositionRule, // SDL-specific validation rules
220
200
  LoneSchemaDefinitionRule,
221
201
  UniqueOperationTypesRule,
222
202
  UniqueTypeNamesRule,
@@ -224,13 +204,11 @@ export {
224
204
  UniqueFieldDefinitionNamesRule,
225
205
  UniqueArgumentDefinitionNamesRule,
226
206
  UniqueDirectiveNamesRule,
227
- PossibleTypeExtensionsRule,
228
- /** Custom validation rules */
207
+ PossibleTypeExtensionsRule, // Custom validation rules
229
208
  NoDeprecatedCustomRule,
230
209
  NoSchemaIntrospectionCustomRule,
231
210
  } from './validation/index.mjs';
232
-
233
- /** Create, format, and print GraphQL errors. */
211
+ // Create, format, and print GraphQL errors.
234
212
  export {
235
213
  GraphQLError,
236
214
  syntaxError,
@@ -238,64 +216,37 @@ export {
238
216
  printError,
239
217
  formatError,
240
218
  } from './error/index.mjs';
241
-
242
- /** Utilities for operating on GraphQL type schema and parsed sources. */
219
+ // Utilities for operating on GraphQL type schema and parsed sources.
243
220
  export {
244
- /**
245
- * Produce the GraphQL query recommended for a full schema introspection.
246
- * Accepts optional IntrospectionOptions.
247
- */
248
- getIntrospectionQuery,
249
- /** Gets the target Operation from a Document. */
250
- getOperationAST,
251
- /** Gets the Type for the target Operation AST. */
252
- getOperationRootType,
253
- /** Convert a GraphQLSchema to an IntrospectionQuery. */
254
- introspectionFromSchema,
255
- /** Build a GraphQLSchema from an introspection result. */
256
- buildClientSchema,
257
- /** Build a GraphQLSchema from a parsed GraphQL Schema language AST. */
258
- buildASTSchema,
259
- /** Build a GraphQLSchema from a GraphQL schema language document. */
260
- buildSchema,
261
- /** Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST. */
262
- extendSchema,
263
- /** Sort a GraphQLSchema. */
264
- lexicographicSortSchema,
265
- /** Print a GraphQLSchema to GraphQL Schema language. */
266
- printSchema,
267
- /** Print a GraphQLType to GraphQL Schema language. */
268
- printType,
269
- /** Prints the built-in introspection schema in the Schema Language format. */
270
- printIntrospectionSchema,
271
- /** Create a GraphQLType from a GraphQL language AST. */
272
- typeFromAST,
273
- /** Create a JavaScript value from a GraphQL language AST with a Type. */
274
- valueFromAST,
275
- /** Create a JavaScript value from a GraphQL language AST without a Type. */
276
- valueFromASTUntyped,
277
- /** Create a GraphQL language AST from a JavaScript value. */
278
- astFromValue,
279
- /** A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. */
221
+ // Produce the GraphQL query recommended for a full schema introspection.
222
+ // Accepts optional IntrospectionOptions.
223
+ getIntrospectionQuery, // Gets the target Operation from a Document.
224
+ getOperationAST, // Gets the Type for the target Operation AST.
225
+ getOperationRootType, // Convert a GraphQLSchema to an IntrospectionQuery.
226
+ introspectionFromSchema, // Build a GraphQLSchema from an introspection result.
227
+ buildClientSchema, // Build a GraphQLSchema from a parsed GraphQL Schema language AST.
228
+ buildASTSchema, // Build a GraphQLSchema from a GraphQL schema language document.
229
+ buildSchema, // Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.
230
+ extendSchema, // Sort a GraphQLSchema.
231
+ lexicographicSortSchema, // Print a GraphQLSchema to GraphQL Schema language.
232
+ printSchema, // Print a GraphQLType to GraphQL Schema language.
233
+ printType, // Prints the built-in introspection schema in the Schema Language format.
234
+ printIntrospectionSchema, // Create a GraphQLType from a GraphQL language AST.
235
+ typeFromAST, // Create a JavaScript value from a GraphQL language AST with a Type.
236
+ valueFromAST, // Create a JavaScript value from a GraphQL language AST without a Type.
237
+ valueFromASTUntyped, // Create a GraphQL language AST from a JavaScript value.
238
+ astFromValue, // A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.
280
239
  TypeInfo,
281
- visitWithTypeInfo,
282
- /** Coerces a JavaScript value to a GraphQL type, or produces errors. */
283
- coerceInputValue,
284
- /** Concatenates multiple AST together. */
285
- concatAST,
286
- /** Separates an AST into an AST per Operation. */
287
- separateOperations,
288
- /** Strips characters that are not significant to the validity or execution of a GraphQL document. */
289
- stripIgnoredCharacters,
290
- /** Comparators for types */
240
+ visitWithTypeInfo, // Coerces a JavaScript value to a GraphQL type, or produces errors.
241
+ coerceInputValue, // Concatenates multiple AST together.
242
+ concatAST, // Separates an AST into an AST per Operation.
243
+ separateOperations, // Strips characters that are not significant to the validity or execution of a GraphQL document.
244
+ stripIgnoredCharacters, // Comparators for types
291
245
  isEqualType,
292
246
  isTypeSubTypeOf,
293
- doTypesOverlap,
294
- /** Asserts a string is a valid GraphQL name. */
295
- assertValidName,
296
- /** Determine if a string is a valid GraphQL name. */
297
- isValidNameError,
298
- /** Compares two GraphQLSchemas and detects breaking changes. */
247
+ doTypesOverlap, // Asserts a string is a valid GraphQL name.
248
+ assertValidName, // Determine if a string is a valid GraphQL name.
249
+ isValidNameError, // Compares two GraphQLSchemas and detects breaking changes.
299
250
  BreakingChangeType,
300
251
  DangerousChangeType,
301
252
  findBreakingChanges,
@@ -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;
@@ -1,4 +1,5 @@
1
1
  import { isPromise } from './isPromise.mjs';
2
+
2
3
  /**
3
4
  * Similar to Array.prototype.reduce(), however the reducing callback may return
4
5
  * a Promise, in which case reduction will continue after each promise resolves.
@@ -6,7 +7,6 @@ import { isPromise } from './isPromise.mjs';
6
7
  * If the callback does not return a Promise, then this function will also not
7
8
  * return a Promise.
8
9
  */
9
-
10
10
  export function promiseReduce(values, callbackFn, initialValue) {
11
11
  let accumulator = initialValue;
12
12
 
@@ -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;