graphql 14.5.0 → 14.5.4

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 (101) hide show
  1. package/error/GraphQLError.d.ts +21 -12
  2. package/error/formatError.d.ts +1 -1
  3. package/error/formatError.js +3 -0
  4. package/error/formatError.js.flow +22 -0
  5. package/error/formatError.mjs +3 -0
  6. package/error/index.d.ts +1 -2
  7. package/error/locatedError.d.ts +1 -1
  8. package/execution/execute.d.ts +33 -30
  9. package/execution/index.d.ts +3 -1
  10. package/execution/values.d.ts +12 -11
  11. package/graphql.d.ts +5 -2
  12. package/index.d.ts +107 -54
  13. package/jsutils/Path.d.ts +14 -0
  14. package/language/ast.d.ts +1 -1
  15. package/language/blockString.d.ts +14 -0
  16. package/language/index.d.ts +6 -3
  17. package/language/lexer.d.ts +3 -40
  18. package/language/parser.d.ts +1 -27
  19. package/language/printLocation.d.ts +16 -0
  20. package/language/tokenKind.d.ts +35 -0
  21. package/language/visitor.d.ts +107 -15
  22. package/package.json +2 -1
  23. package/polyfills/flatMap.js +5 -3
  24. package/polyfills/flatMap.js.flow +5 -2
  25. package/polyfills/flatMap.mjs +5 -2
  26. package/polyfills/isFinite.js +2 -2
  27. package/polyfills/isFinite.js.flow +5 -4
  28. package/polyfills/isFinite.mjs +2 -2
  29. package/subscription/asyncIteratorReject.d.ts +6 -0
  30. package/subscription/index.d.ts +5 -1
  31. package/subscription/mapAsyncIterator.d.ts +11 -0
  32. package/subscription/subscribe.d.ts +16 -12
  33. package/type/definition.d.ts +54 -23
  34. package/type/definition.js +10 -6
  35. package/type/definition.js.flow +2 -3
  36. package/type/definition.mjs +10 -6
  37. package/type/directives.d.ts +10 -2
  38. package/type/directives.js +1 -1
  39. package/type/directives.js.flow +1 -1
  40. package/type/directives.mjs +1 -1
  41. package/type/index.d.ts +6 -1
  42. package/type/introspection.d.ts +3 -8
  43. package/type/scalars.d.ts +1 -1
  44. package/type/schema.d.ts +9 -3
  45. package/type/validate.d.ts +1 -1
  46. package/utilities/TypeInfo.d.ts +4 -4
  47. package/utilities/buildASTSchema.d.ts +13 -11
  48. package/utilities/coerceInputValue.d.ts +17 -0
  49. package/utilities/coerceValue.d.ts +2 -6
  50. package/utilities/extendSchema.d.ts +1 -2
  51. package/utilities/findBreakingChanges.d.ts +9 -135
  52. package/utilities/findDeprecatedUsages.d.ts +2 -2
  53. package/utilities/getOperationRootType.d.ts +1 -1
  54. package/utilities/index.d.ts +7 -0
  55. package/utilities/separateOperations.d.ts +1 -1
  56. package/utilities/stripIgnoredCharacters.d.ts +55 -0
  57. package/utilities/typeComparators.d.ts +1 -5
  58. package/utilities/typeFromAST.d.ts +2 -9
  59. package/utilities/valueFromAST.d.ts +1 -6
  60. package/validation/ValidationContext.d.ts +23 -14
  61. package/validation/index.d.ts +1 -1
  62. package/validation/rules/ExecutableDefinitions.d.ts +1 -1
  63. package/validation/rules/FieldsOnCorrectType.d.ts +8 -1
  64. package/validation/rules/FragmentsOnCompositeTypes.d.ts +1 -1
  65. package/validation/rules/KnownArgumentNames.d.ts +2 -2
  66. package/validation/rules/KnownDirectives.d.ts +1 -1
  67. package/validation/rules/KnownFragmentNames.d.ts +1 -1
  68. package/validation/rules/KnownTypeNames.d.ts +1 -1
  69. package/validation/rules/LoneAnonymousOperation.d.ts +1 -1
  70. package/validation/rules/LoneSchemaDefinition.d.ts +1 -1
  71. package/validation/rules/NoFragmentCycles.d.ts +2 -2
  72. package/validation/rules/NoUndefinedVariables.d.ts +1 -1
  73. package/validation/rules/NoUnusedFragments.d.ts +1 -1
  74. package/validation/rules/NoUnusedVariables.d.ts +1 -1
  75. package/validation/rules/OverlappingFieldsCanBeMerged.d.ts +1 -1
  76. package/validation/rules/PossibleFragmentSpreads.d.ts +1 -1
  77. package/validation/rules/PossibleTypeExtensions.d.ts +21 -0
  78. package/validation/rules/ProvidedRequiredArguments.d.ts +1 -1
  79. package/validation/rules/ScalarLeafs.d.ts +1 -1
  80. package/validation/rules/SingleFieldSubscriptions.d.ts +1 -1
  81. package/validation/rules/UniqueArgumentNames.d.ts +1 -1
  82. package/validation/rules/UniqueDirectiveNames.d.ts +13 -0
  83. package/validation/rules/UniqueDirectivesPerLocation.d.ts +1 -1
  84. package/validation/rules/UniqueEnumValueNames.d.ts +19 -0
  85. package/validation/rules/UniqueFieldDefinitionNames.d.ts +21 -0
  86. package/validation/rules/UniqueFragmentNames.d.ts +1 -1
  87. package/validation/rules/UniqueInputFieldNames.d.ts +1 -1
  88. package/validation/rules/UniqueOperationNames.d.ts +1 -1
  89. package/validation/rules/UniqueOperationTypes.d.ts +13 -0
  90. package/validation/rules/UniqueTypeNames.d.ts +13 -0
  91. package/validation/rules/UniqueVariableNames.d.ts +1 -1
  92. package/validation/rules/ValuesOfCorrectType.d.ts +8 -2
  93. package/validation/rules/VariablesAreInputTypes.d.ts +1 -1
  94. package/validation/rules/VariablesInAllowedPosition.d.ts +1 -1
  95. package/validation/specifiedRules.d.ts +8 -2
  96. package/validation/validate.d.ts +4 -2
  97. package/version.d.ts +14 -0
  98. package/version.js +2 -2
  99. package/version.js.flow +2 -2
  100. package/version.mjs +2 -2
  101. package/error/printError.d.ts +0 -7
@@ -0,0 +1,14 @@
1
+ export type Path = {
2
+ prev: Path | undefined;
3
+ key: string | number;
4
+ };
5
+
6
+ /**
7
+ * Given a Path and a key, return a new Path containing the new key.
8
+ */
9
+ export function addPath(prev: Path | undefined, key: string | number): Path;
10
+
11
+ /**
12
+ * Given a Path, return an Array of the path keys.
13
+ */
14
+ export function pathToArray(path: Path): Array<string | number>;
package/language/ast.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Source } from './source';
2
- import { TokenKindEnum } from './lexer';
2
+ import { TokenKindEnum } from './tokenKind';
3
3
 
4
4
  /**
5
5
  * Contains a range of UTF-8 character offsets and token references that
@@ -5,3 +5,17 @@
5
5
  * This implements the GraphQL spec's BlockStringValue() static algorithm.
6
6
  */
7
7
  export function dedentBlockStringValue(rawString: string): string;
8
+
9
+ // @internal
10
+ export function getBlockStringIndentation(lines: ReadonlyArray<string>): number;
11
+
12
+ /**
13
+ * Print a block string in the indented block form by adding a leading and
14
+ * trailing blank line. However, if a block string starts with whitespace and is
15
+ * a single-line, adding a leading blank line would strip that whitespace.
16
+ */
17
+ export function printBlockString(
18
+ value: string,
19
+ indentation?: string,
20
+ preferMultipleLines?: boolean,
21
+ ): string;
@@ -1,16 +1,19 @@
1
+ export { Source } from './source';
1
2
  export { getLocation, SourceLocation } from './location';
3
+
4
+ export { printLocation, printSourceLocation } from './printLocation';
5
+
2
6
  export { Kind, KindEnum } from './kinds';
3
- export { createLexer, TokenKind, Lexer, TokenKindEnum } from './lexer';
7
+ export { TokenKind, TokenKindEnum } from './tokenKind';
8
+ export { createLexer, Lexer } from './lexer';
4
9
  export { parse, parseValue, parseType, ParseOptions } from './parser';
5
10
  export { print } from './printer';
6
- export { Source } from './source';
7
11
  export {
8
12
  visit,
9
13
  visitInParallel,
10
14
  visitWithTypeInfo,
11
15
  getVisitFn,
12
16
  BREAK,
13
- // type
14
17
  ASTVisitor,
15
18
  Visitor,
16
19
  VisitFn,
@@ -1,6 +1,6 @@
1
+ import { syntaxError } from '../error';
1
2
  import { Token } from './ast';
2
3
  import { Source } from './source';
3
- import { syntaxError } from '../error';
4
4
 
5
5
  /**
6
6
  * Given a Source object, this returns a Lexer for that source.
@@ -55,43 +55,6 @@ export interface Lexer<TOptions> {
55
55
  }
56
56
 
57
57
  /**
58
- * An exported enum describing the different kinds of tokens that the
59
- * lexer emits.
60
- */
61
- export const TokenKind: _TokenKind;
62
-
63
- // @internal
64
- type _TokenKind = {
65
- SOF: '<SOF>';
66
- EOF: '<EOF>';
67
- BANG: '!';
68
- DOLLAR: '$';
69
- AMP: '&';
70
- PAREN_L: '(';
71
- PAREN_R: ')';
72
- SPREAD: '...';
73
- COLON: ':';
74
- EQUALS: '=';
75
- AT: '@';
76
- BRACKET_L: '[';
77
- BRACKET_R: ']';
78
- BRACE_L: '{';
79
- PIPE: '|';
80
- BRACE_R: '}';
81
- NAME: 'Name';
82
- INT: 'Int';
83
- FLOAT: 'Float';
84
- STRING: 'String';
85
- BLOCK_STRING: 'BlockString';
86
- COMMENT: 'Comment';
87
- };
88
-
89
- /**
90
- * The enum type representing the token kinds values.
91
- */
92
- export type TokenKindEnum = _TokenKind[keyof _TokenKind];
93
-
94
- /**
95
- * A helper function to describe a token as a string for debugging
58
+ * @internal
96
59
  */
97
- export function getTokenDesc(token: Token): string;
60
+ export function isPunctuatorToken(token: Token): boolean;
@@ -1,6 +1,6 @@
1
- import { NamedTypeNode, TypeNode, ValueNode, DocumentNode } from './ast';
2
1
  import { Source } from './source';
3
2
  import { Lexer } from './lexer';
3
+ import { NamedTypeNode, TypeNode, ValueNode, DocumentNode } from './ast';
4
4
 
5
5
  /**
6
6
  * Configuration options to control parser behavior
@@ -50,17 +50,6 @@ export interface ParseOptions {
50
50
  * future.
51
51
  */
52
52
  experimentalFragmentVariables?: boolean;
53
-
54
- /**
55
- * EXPERIMENTAL:
56
- *
57
- * If enabled, the parser understands directives on variable definitions:
58
- *
59
- * query Foo($var: String = "abc" @variable_definition_directive) {
60
- * ...
61
- * }
62
- */
63
- experimentalVariableDefinitionDirectives?: boolean;
64
53
  }
65
54
 
66
55
  /**
@@ -98,18 +87,3 @@ export function parseType(
98
87
  source: string | Source,
99
88
  options?: ParseOptions,
100
89
  ): TypeNode;
101
-
102
- export function parseConstValue<TOptions>(lexer: Lexer<TOptions>): ValueNode;
103
-
104
- /**
105
- * Type :
106
- * - NamedType
107
- * - ListType
108
- * - NonNullType
109
- */
110
- export function parseTypeReference<TOptions>(lexer: Lexer<TOptions>): TypeNode;
111
-
112
- /**
113
- * NamedType : Name
114
- */
115
- export function parseNamedType<TOptions>(lexer: Lexer<TOptions>): NamedTypeNode;
@@ -0,0 +1,16 @@
1
+ import { Location } from '../language/ast';
2
+ import { Source } from '../language/source';
3
+ import { SourceLocation } from '../language/location';
4
+
5
+ /**
6
+ * Render a helpful description of the location in the GraphQL Source document.
7
+ */
8
+ export function printLocation(location: Location): string;
9
+
10
+ /**
11
+ * Render a helpful description of the location in the GraphQL Source document.
12
+ */
13
+ export function printSourceLocation(
14
+ source: Source,
15
+ sourceLocation: SourceLocation,
16
+ ): string;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * An exported enum describing the different kinds of tokens that the
3
+ * lexer emits.
4
+ */
5
+ export const TokenKind: _TokenKind;
6
+
7
+ type _TokenKind = {
8
+ SOF: '<SOF>';
9
+ EOF: '<EOF>';
10
+ BANG: '!';
11
+ DOLLAR: '$';
12
+ AMP: '&';
13
+ PAREN_L: '(';
14
+ PAREN_R: ')';
15
+ SPREAD: '...';
16
+ COLON: ':';
17
+ EQUALS: '=';
18
+ AT: '@';
19
+ BRACKET_L: '[';
20
+ BRACKET_R: ']';
21
+ BRACE_L: '{';
22
+ PIPE: '|';
23
+ BRACE_R: '}';
24
+ NAME: 'Name';
25
+ INT: 'Int';
26
+ FLOAT: 'Float';
27
+ STRING: 'String';
28
+ BLOCK_STRING: 'BlockString';
29
+ COMMENT: 'Comment';
30
+ };
31
+
32
+ /**
33
+ * The enum type representing the token kinds values.
34
+ */
35
+ export type TokenKindEnum = _TokenKind[keyof _TokenKind];
@@ -1,6 +1,15 @@
1
1
  import Maybe from '../tsutils/Maybe';
2
- import { ASTNode, ASTKindToNode } from './ast';
3
2
  import { TypeInfo } from '../utilities/TypeInfo';
3
+ import { ASTNode, ASTKindToNode } from './ast';
4
+
5
+ /**
6
+ * A visitor is provided to visit, it contains the collection of
7
+ * relevant functions to be called during the visitor's traversal.
8
+ */
9
+ export type ASTVisitor = Visitor<ASTKindToNode>;
10
+ export type Visitor<KindToNode, Nodes = KindToNode[keyof KindToNode]> =
11
+ | EnterLeaveVisitor<KindToNode, Nodes>
12
+ | ShapeMapVisitor<KindToNode, Nodes>;
4
13
 
5
14
  interface EnterLeave<T> {
6
15
  readonly enter?: T;
@@ -17,27 +26,23 @@ type ShapeMapVisitor<KindToNode, Nodes> = {
17
26
  | EnterLeave<VisitFn<Nodes, KindToNode[K]>>;
18
27
  };
19
28
 
20
- export type ASTVisitor = Visitor<ASTKindToNode>;
21
- export type Visitor<KindToNode, Nodes = KindToNode[keyof KindToNode]> =
22
- | EnterLeaveVisitor<KindToNode, Nodes>
23
- | ShapeMapVisitor<KindToNode, Nodes>;
24
-
25
29
  /**
26
30
  * A visitor is comprised of visit functions, which are called on each node
27
31
  * during the visitor's traversal.
28
32
  */
29
33
  export type VisitFn<TAnyNode, TVisitedNode = TAnyNode> = (
30
- // The current node being visiting.
34
+ /** The current node being visiting.*/
31
35
  node: TVisitedNode,
32
- // The index or key to this node from the parent node or Array.
36
+ /** The index or key to this node from the parent node or Array. */
33
37
  key: string | number | undefined,
34
- // The parent immediately above this node, which may be an Array.
38
+ /** The parent immediately above this node, which may be an Array. */
35
39
  parent: TAnyNode | ReadonlyArray<TAnyNode> | undefined,
36
- // The key path to get to this node from the root node.
40
+ /** The key path to get to this node from the root node. */
37
41
  path: ReadonlyArray<string | number>,
38
- // All nodes and Arrays visited before reaching parent of this node.
39
- // These correspond to array indices in `path`.
40
- // Note: ancestors includes arrays which contain the parent of visited node.
42
+ /** All nodes and Arrays visited before reaching parent of this node.
43
+ * These correspond to array indices in `path`.
44
+ * Note: ancestors includes arrays which contain the parent of visited node.
45
+ */
41
46
  ancestors: ReadonlyArray<TAnyNode | ReadonlyArray<TAnyNode>>,
42
47
  ) => any;
43
48
 
@@ -46,7 +51,94 @@ export type VisitFn<TAnyNode, TVisitedNode = TAnyNode> = (
46
51
  */
47
52
  export type VisitorKeyMap<T> = { [P in keyof T]: ReadonlyArray<keyof T[P]> };
48
53
 
49
- export const QueryDocumentKeys: { [key: string]: string[] };
54
+ // TODO: Should be `[]`, but that requires TypeScript@3
55
+ type EmptyTuple = never[];
56
+
57
+ export const QueryDocumentKeys: {
58
+ Name: EmptyTuple;
59
+
60
+ Document: ['definitions'];
61
+ // Prettier forces trailing commas, but TS pre 3.2 doesn't allow them.
62
+ // prettier-ignore
63
+ OperationDefinition: [
64
+ 'name',
65
+ 'variableDefinitions',
66
+ 'directives',
67
+ 'selectionSet'
68
+ ];
69
+ VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'];
70
+ Variable: ['name'];
71
+ SelectionSet: ['selections'];
72
+ Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'];
73
+ Argument: ['name', 'value'];
74
+
75
+ FragmentSpread: ['name', 'directives'];
76
+ InlineFragment: ['typeCondition', 'directives', 'selectionSet'];
77
+ // prettier-ignore
78
+ FragmentDefinition: [
79
+ 'name',
80
+ // Note: fragment variable definitions are experimental and may be changed
81
+ // or removed in the future.
82
+ 'variableDefinitions',
83
+ 'typeCondition',
84
+ 'directives',
85
+ 'selectionSet'
86
+ ];
87
+
88
+ IntValue: EmptyTuple;
89
+ FloatValue: EmptyTuple;
90
+ StringValue: EmptyTuple;
91
+ BooleanValue: EmptyTuple;
92
+ NullValue: EmptyTuple;
93
+ EnumValue: EmptyTuple;
94
+ ListValue: ['values'];
95
+ ObjectValue: ['fields'];
96
+ ObjectField: ['name', 'value'];
97
+
98
+ Directive: ['name', 'arguments'];
99
+
100
+ NamedType: ['name'];
101
+ ListType: ['type'];
102
+ NonNullType: ['type'];
103
+
104
+ SchemaDefinition: ['directives', 'operationTypes'];
105
+ OperationTypeDefinition: ['type'];
106
+
107
+ ScalarTypeDefinition: ['description', 'name', 'directives'];
108
+ // prettier-ignore
109
+ ObjectTypeDefinition: [
110
+ 'description',
111
+ 'name',
112
+ 'interfaces',
113
+ 'directives',
114
+ 'fields'
115
+ ];
116
+ FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'];
117
+ // prettier-ignore
118
+ InputValueDefinition: [
119
+ 'description',
120
+ 'name',
121
+ 'type',
122
+ 'defaultValue',
123
+ 'directives'
124
+ ];
125
+ InterfaceTypeDefinition: ['description', 'name', 'directives', 'fields'];
126
+ UnionTypeDefinition: ['description', 'name', 'directives', 'types'];
127
+ EnumTypeDefinition: ['description', 'name', 'directives', 'values'];
128
+ EnumValueDefinition: ['description', 'name', 'directives'];
129
+ InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'];
130
+
131
+ DirectiveDefinition: ['description', 'name', 'arguments', 'locations'];
132
+
133
+ SchemaExtension: ['directives', 'operationTypes'];
134
+
135
+ ScalarTypeExtension: ['name', 'directives'];
136
+ ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'];
137
+ InterfaceTypeExtension: ['name', 'directives', 'fields'];
138
+ UnionTypeExtension: ['name', 'directives', 'types'];
139
+ EnumTypeExtension: ['name', 'directives', 'values'];
140
+ InputObjectTypeExtension: ['name', 'directives', 'fields'];
141
+ };
50
142
 
51
143
  export const BREAK: any;
52
144
 
@@ -149,7 +241,7 @@ export function visit(
149
241
  * If a prior visitor edits a node, no following visitors will see that node.
150
242
  */
151
243
  export function visitInParallel(
152
- visitors: Array<Visitor<ASTKindToNode>>,
244
+ visitors: ReadonlyArray<Visitor<ASTKindToNode>>,
153
245
  ): Visitor<ASTKindToNode>;
154
246
 
155
247
  /**
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "graphql",
3
- "version": "14.5.0",
3
+ "version": "14.5.4",
4
4
  "description": "A Query Language and Runtime which can target any service.",
5
5
  "license": "MIT",
6
6
  "main": "index",
7
7
  "module": "index.mjs",
8
+ "types": "index.d.ts",
8
9
  "sideEffects": false,
9
10
  "homepage": "https://github.com/graphql/graphql-js",
10
11
  "bugs": {
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
7
+ // Workaround to make older Flow versions happy
8
+ var flatMapMethod = Array.prototype.flatMap;
8
9
  /* eslint-disable no-redeclare */
9
10
  // $FlowFixMe
10
- var flatMap = Array.prototype.flatMap ? function (list, fn) {
11
- return Array.prototype.flatMap.call(list, fn);
11
+
12
+ var flatMap = flatMapMethod ? function (list, fn) {
13
+ return flatMapMethod.call(list, fn);
12
14
  } : function (list, fn) {
13
15
  var result = [];
14
16
 
@@ -5,11 +5,14 @@ declare function flatMap<T, U>(
5
5
  fn: (item: T, index: number) => $ReadOnlyArray<U> | U,
6
6
  ): Array<U>;
7
7
 
8
+ // Workaround to make older Flow versions happy
9
+ const flatMapMethod = (Array.prototype: any).flatMap;
10
+
8
11
  /* eslint-disable no-redeclare */
9
12
  // $FlowFixMe
10
- const flatMap = Array.prototype.flatMap
13
+ const flatMap = flatMapMethod
11
14
  ? function(list, fn) {
12
- return Array.prototype.flatMap.call(list, fn);
15
+ return flatMapMethod.call(list, fn);
13
16
  }
14
17
  : function(list, fn) {
15
18
  let result = [];
@@ -1,7 +1,10 @@
1
+ // Workaround to make older Flow versions happy
2
+ var flatMapMethod = Array.prototype.flatMap;
1
3
  /* eslint-disable no-redeclare */
2
4
  // $FlowFixMe
3
- var flatMap = Array.prototype.flatMap ? function (list, fn) {
4
- return Array.prototype.flatMap.call(list, fn);
5
+
6
+ var flatMap = flatMapMethod ? function (list, fn) {
7
+ return flatMapMethod.call(list, fn);
5
8
  } : function (list, fn) {
6
9
  var result = [];
7
10
 
@@ -7,9 +7,9 @@ exports.default = void 0;
7
7
 
8
8
  /* eslint-disable no-redeclare */
9
9
  // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
10
- var isFinite = Number.isFinite || function (value) {
10
+ var isFinitePolyfill = Number.isFinite || function (value) {
11
11
  return typeof value === 'number' && isFinite(value);
12
12
  };
13
13
 
14
- var _default = isFinite;
14
+ var _default = isFinitePolyfill;
15
15
  exports.default = _default;
@@ -1,13 +1,14 @@
1
1
  // @flow strict
2
2
 
3
- declare function isFinite(value: mixed): boolean %checks(typeof value ===
4
- 'number');
3
+ declare function isFinitePolyfill(
4
+ value: mixed,
5
+ ): boolean %checks(typeof value === 'number');
5
6
 
6
7
  /* eslint-disable no-redeclare */
7
8
  // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
8
- const isFinite =
9
+ const isFinitePolyfill =
9
10
  Number.isFinite ||
10
11
  function(value) {
11
12
  return typeof value === 'number' && isFinite(value);
12
13
  };
13
- export default isFinite;
14
+ export default isFinitePolyfill;
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-redeclare */
2
2
  // $FlowFixMe workaround for: https://github.com/facebook/flow/issues/4441
3
- var isFinite = Number.isFinite || function (value) {
3
+ var isFinitePolyfill = Number.isFinite || function (value) {
4
4
  return typeof value === 'number' && isFinite(value);
5
5
  };
6
6
 
7
- export default isFinite;
7
+ export default isFinitePolyfill;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Given an error, returns an AsyncIterable which will fail with that error.
3
+ *
4
+ * Similar to Promise.reject(error)
5
+ */
6
+ export default function asyncIteratorReject(error: Error): AsyncIterator<void>;
@@ -1 +1,5 @@
1
- export { subscribe, createSourceEventStream } from './subscribe';
1
+ export {
2
+ subscribe,
3
+ createSourceEventStream,
4
+ SubscriptionArgs,
5
+ } from './subscribe';
@@ -0,0 +1,11 @@
1
+ import { PromiseOrValue } from '../jsutils/PromiseOrValue';
2
+
3
+ /**
4
+ * Given an AsyncIterable and a callback function, return an AsyncIterator
5
+ * which produces values mapped via calling the callback function.
6
+ */
7
+ export default function mapAsyncIterator<T, U>(
8
+ iterable: AsyncIterable<T>,
9
+ callback: (arg: T) => PromiseOrValue<U>,
10
+ rejectCallback?: (arg: any) => PromiseOrValue<U>,
11
+ ): any; // TS_SPECIFIC: es2018.asyncgenerator requires typescript@3.6
@@ -1,11 +1,22 @@
1
1
  import Maybe from '../tsutils/Maybe';
2
- import { GraphQLSchema } from '../type/schema';
3
2
  import { DocumentNode } from '../language/ast';
4
- import { GraphQLFieldResolver } from '../type/definition';
5
3
  import {
6
4
  ExecutionResult,
7
5
  ExecutionResultDataDefault,
8
6
  } from '../execution/execute';
7
+ import { GraphQLSchema } from '../type/schema';
8
+ import { GraphQLFieldResolver } from '../type/definition';
9
+
10
+ export interface SubscriptionArgs {
11
+ schema: GraphQLSchema;
12
+ document: DocumentNode;
13
+ rootValue?: any;
14
+ contextValue?: any;
15
+ variableValues?: Maybe<Record<string, any>>;
16
+ operationName?: Maybe<string>;
17
+ fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
18
+ subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
19
+ }
9
20
 
10
21
  /**
11
22
  * Implements the "Subscribe" algorithm described in the GraphQL specification.
@@ -27,16 +38,9 @@ import {
27
38
  *
28
39
  * Accepts either an object with named arguments, or individual arguments.
29
40
  */
30
- export function subscribe<TData = ExecutionResultDataDefault>(args: {
31
- schema: GraphQLSchema;
32
- document: DocumentNode;
33
- rootValue?: any;
34
- contextValue?: any;
35
- variableValues?: Maybe<{ [key: string]: any }>;
36
- operationName?: Maybe<string>;
37
- fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
38
- subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
39
- }): Promise<
41
+ export function subscribe<TData = ExecutionResultDataDefault>(
42
+ args: SubscriptionArgs,
43
+ ): Promise<
40
44
  AsyncIterableIterator<ExecutionResult<TData>> | ExecutionResult<TData>
41
45
  >;
42
46