@graphql-tools/executor 0.0.1-alpha-20221025014654-e3be5659

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 (35) hide show
  1. package/README.md +3 -0
  2. package/cjs/execution/AccumulatorMap.js +21 -0
  3. package/cjs/execution/collectFields.js +114 -0
  4. package/cjs/execution/execute.js +792 -0
  5. package/cjs/execution/index.js +10 -0
  6. package/cjs/execution/mapAsyncIterator.js +53 -0
  7. package/cjs/execution/subscribe.js +164 -0
  8. package/cjs/execution/values.js +168 -0
  9. package/cjs/index.js +4 -0
  10. package/cjs/package.json +1 -0
  11. package/esm/execution/AccumulatorMap.js +17 -0
  12. package/esm/execution/collectFields.js +109 -0
  13. package/esm/execution/execute.js +779 -0
  14. package/esm/execution/index.js +5 -0
  15. package/esm/execution/mapAsyncIterator.js +49 -0
  16. package/esm/execution/subscribe.js +159 -0
  17. package/esm/execution/values.js +162 -0
  18. package/esm/index.js +1 -0
  19. package/package.json +58 -0
  20. package/typings/execution/AccumulatorMap.d.cts +7 -0
  21. package/typings/execution/AccumulatorMap.d.ts +7 -0
  22. package/typings/execution/collectFields.d.cts +27 -0
  23. package/typings/execution/collectFields.d.ts +27 -0
  24. package/typings/execution/execute.d.cts +196 -0
  25. package/typings/execution/execute.d.ts +196 -0
  26. package/typings/execution/index.d.cts +5 -0
  27. package/typings/execution/index.d.ts +5 -0
  28. package/typings/execution/mapAsyncIterator.d.cts +6 -0
  29. package/typings/execution/mapAsyncIterator.d.ts +6 -0
  30. package/typings/execution/subscribe.d.cts +56 -0
  31. package/typings/execution/subscribe.d.ts +56 -0
  32. package/typings/execution/values.d.cts +54 -0
  33. package/typings/execution/values.d.ts +54 -0
  34. package/typings/index.d.cts +1 -0
  35. package/typings/index.d.ts +1 -0
@@ -0,0 +1,196 @@
1
+ import type { Maybe } from 'graphql/jsutils/Maybe.cjs';
2
+ import type { ObjMap } from 'graphql/jsutils/ObjMap.cjs';
3
+ import type { Path } from 'graphql/jsutils/Path.cjs';
4
+ import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue.cjs';
5
+ import { GraphQLFormattedError, GraphQLError, DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, GraphQLField, GraphQLFieldResolver, GraphQLObjectType, GraphQLResolveInfo, GraphQLTypeResolver, GraphQLSchema } from 'graphql';
6
+ /**
7
+ * Terminology
8
+ *
9
+ * "Definitions" are the generic name for top-level statements in the document.
10
+ * Examples of this include:
11
+ * 1) Operations (such as a query)
12
+ * 2) Fragments
13
+ *
14
+ * "Operations" are a generic name for requests in the document.
15
+ * Examples of this include:
16
+ * 1) query,
17
+ * 2) mutation
18
+ *
19
+ * "Selections" are the definitions that can appear legally and at
20
+ * single level of the query. These include:
21
+ * 1) field references e.g `a`
22
+ * 2) fragment "spreads" e.g. `...c`
23
+ * 3) inline fragment "spreads" e.g. `...on Type { a }`
24
+ */
25
+ /**
26
+ * Data that must be available at all points during query execution.
27
+ *
28
+ * Namely, schema of the type system that is currently executing,
29
+ * and the fragments defined in the query document
30
+ */
31
+ export interface ExecutionContext {
32
+ schema: GraphQLSchema;
33
+ fragments: ObjMap<FragmentDefinitionNode>;
34
+ rootValue: unknown;
35
+ contextValue: unknown;
36
+ operation: OperationDefinitionNode;
37
+ variableValues: {
38
+ [variable: string]: unknown;
39
+ };
40
+ fieldResolver: GraphQLFieldResolver<any, any>;
41
+ typeResolver: GraphQLTypeResolver<any, any>;
42
+ subscribeFieldResolver: GraphQLFieldResolver<any, any>;
43
+ errors: Array<GraphQLError>;
44
+ }
45
+ /**
46
+ * The result of GraphQL execution.
47
+ *
48
+ * - `errors` is included when any errors occurred as a non-empty array.
49
+ * - `data` is the result of a successful execution of the query.
50
+ * - `extensions` is reserved for adding non-standard properties.
51
+ */
52
+ export interface ExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
53
+ errors?: ReadonlyArray<GraphQLError>;
54
+ data?: TData | null;
55
+ extensions?: TExtensions;
56
+ }
57
+ export interface FormattedExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
58
+ errors?: ReadonlyArray<GraphQLFormattedError>;
59
+ data?: TData | null;
60
+ extensions?: TExtensions;
61
+ }
62
+ export interface ExecutionArgs {
63
+ schema: GraphQLSchema;
64
+ document: DocumentNode;
65
+ rootValue?: unknown;
66
+ contextValue?: unknown;
67
+ variableValues?: Maybe<{
68
+ readonly [variable: string]: unknown;
69
+ }>;
70
+ operationName?: Maybe<string>;
71
+ fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
72
+ typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
73
+ subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
74
+ }
75
+ /**
76
+ * Implements the "Executing requests" section of the GraphQL specification.
77
+ *
78
+ * Returns either a synchronous ExecutionResult (if all encountered resolvers
79
+ * are synchronous), or a Promise of an ExecutionResult that will eventually be
80
+ * resolved and never rejected.
81
+ *
82
+ * If the arguments to this function do not result in a legal execution context,
83
+ * a GraphQLError will be thrown immediately explaining the invalid input.
84
+ */
85
+ export declare function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult>;
86
+ /**
87
+ * Also implements the "Executing requests" section of the GraphQL specification.
88
+ * However, it guarantees to complete synchronously (or throw an error) assuming
89
+ * that all field resolvers are also synchronous.
90
+ */
91
+ export declare function executeSync(args: ExecutionArgs): ExecutionResult;
92
+ /**
93
+ * Essential assertions before executing to provide developer feedback for
94
+ * improper use of the GraphQL library.
95
+ *
96
+ * @internal
97
+ */
98
+ export declare function assertValidExecutionArguments(schema: GraphQLSchema, document: DocumentNode, rawVariableValues: Maybe<{
99
+ readonly [variable: string]: unknown;
100
+ }>): void;
101
+ /**
102
+ * Constructs a ExecutionContext object from the arguments passed to
103
+ * execute, which we will pass throughout the other execution methods.
104
+ *
105
+ * Throws a GraphQLError if a valid execution context cannot be created.
106
+ *
107
+ * TODO: consider no longer exporting this function
108
+ * @internal
109
+ */
110
+ export declare function buildExecutionContext(args: ExecutionArgs): ReadonlyArray<GraphQLError> | ExecutionContext;
111
+ /**
112
+ * TODO: consider no longer exporting this function
113
+ * @internal
114
+ */
115
+ export declare function buildResolveInfo(exeContext: ExecutionContext, fieldDef: GraphQLField<unknown, unknown>, fieldNodes: ReadonlyArray<FieldNode>, parentType: GraphQLObjectType, path: Path): GraphQLResolveInfo;
116
+ /**
117
+ * If a resolveType function is not given, then a default resolve behavior is
118
+ * used which attempts two strategies:
119
+ *
120
+ * First, See if the provided value has a `__typename` field defined, if so, use
121
+ * that value as name of the resolved type.
122
+ *
123
+ * Otherwise, test each possible type for the abstract type by calling
124
+ * isTypeOf for the object being coerced, returning the first type that matches.
125
+ */
126
+ export declare const defaultTypeResolver: GraphQLTypeResolver<unknown, unknown>;
127
+ /**
128
+ * If a resolve function is not given, then a default resolve behavior is used
129
+ * which takes the property of the source object of the same name as the field
130
+ * and returns it as the result, or if it's a function, returns the result
131
+ * of calling that function while passing along args and context value.
132
+ */
133
+ export declare const defaultFieldResolver: GraphQLFieldResolver<unknown, unknown>;
134
+ /**
135
+ * Implements the "Subscribe" algorithm described in the GraphQL specification.
136
+ *
137
+ * Returns a Promise which resolves to either an AsyncIterator (if successful)
138
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
139
+ * other arguments to this function are invalid, or if the resolved event stream
140
+ * is not an async iterable.
141
+ *
142
+ * If the client-provided arguments to this function do not result in a
143
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
144
+ * descriptive errors and no data will be returned.
145
+ *
146
+ * If the source stream could not be created due to faulty subscription
147
+ * resolver logic or underlying systems, the promise will resolve to a single
148
+ * ExecutionResult containing `errors` and no `data`.
149
+ *
150
+ * If the operation succeeded, the promise resolves to an AsyncIterator, which
151
+ * yields a stream of ExecutionResults representing the response stream.
152
+ *
153
+ * Accepts either an object with named arguments, or individual arguments.
154
+ */
155
+ export declare function subscribe(args: ExecutionArgs): PromiseOrValue<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult>;
156
+ /**
157
+ * Implements the "CreateSourceEventStream" algorithm described in the
158
+ * GraphQL specification, resolving the subscription source event stream.
159
+ *
160
+ * Returns a Promise which resolves to either an AsyncIterable (if successful)
161
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
162
+ * other arguments to this function are invalid, or if the resolved event stream
163
+ * is not an async iterable.
164
+ *
165
+ * If the client-provided arguments to this function do not result in a
166
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
167
+ * descriptive errors and no data will be returned.
168
+ *
169
+ * If the the source stream could not be created due to faulty subscription
170
+ * resolver logic or underlying systems, the promise will resolve to a single
171
+ * ExecutionResult containing `errors` and no `data`.
172
+ *
173
+ * If the operation succeeded, the promise resolves to the AsyncIterable for the
174
+ * event stream returned by the resolver.
175
+ *
176
+ * A Source Event Stream represents a sequence of events, each of which triggers
177
+ * a GraphQL execution for that event.
178
+ *
179
+ * This may be useful when hosting the stateful subscription service in a
180
+ * different process or machine than the stateless GraphQL execution engine,
181
+ * or otherwise separating these two steps. For more on this, see the
182
+ * "Supporting Subscriptions at Scale" information in the GraphQL specification.
183
+ */
184
+ export declare function createSourceEventStream(args: ExecutionArgs): PromiseOrValue<AsyncIterable<unknown> | ExecutionResult>;
185
+ /**
186
+ * This method looks up the field on the given type definition.
187
+ * It has special casing for the three introspection fields,
188
+ * __schema, __type and __typename. __typename is special because
189
+ * it can always be queried as a field, even in situations where no
190
+ * other fields are allowed, like on a Union. __schema and __type
191
+ * could get automatically added to the query type, but that would
192
+ * require mutating type definitions, which would cause issues.
193
+ *
194
+ * @internal
195
+ */
196
+ export declare function getFieldDef(schema: GraphQLSchema, parentType: GraphQLObjectType, fieldNode: FieldNode): Maybe<GraphQLField<unknown, unknown>>;
@@ -0,0 +1,196 @@
1
+ import type { Maybe } from 'graphql/jsutils/Maybe.js';
2
+ import type { ObjMap } from 'graphql/jsutils/ObjMap.js';
3
+ import type { Path } from 'graphql/jsutils/Path.js';
4
+ import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue.js';
5
+ import { GraphQLFormattedError, GraphQLError, DocumentNode, FieldNode, FragmentDefinitionNode, OperationDefinitionNode, GraphQLField, GraphQLFieldResolver, GraphQLObjectType, GraphQLResolveInfo, GraphQLTypeResolver, GraphQLSchema } from 'graphql';
6
+ /**
7
+ * Terminology
8
+ *
9
+ * "Definitions" are the generic name for top-level statements in the document.
10
+ * Examples of this include:
11
+ * 1) Operations (such as a query)
12
+ * 2) Fragments
13
+ *
14
+ * "Operations" are a generic name for requests in the document.
15
+ * Examples of this include:
16
+ * 1) query,
17
+ * 2) mutation
18
+ *
19
+ * "Selections" are the definitions that can appear legally and at
20
+ * single level of the query. These include:
21
+ * 1) field references e.g `a`
22
+ * 2) fragment "spreads" e.g. `...c`
23
+ * 3) inline fragment "spreads" e.g. `...on Type { a }`
24
+ */
25
+ /**
26
+ * Data that must be available at all points during query execution.
27
+ *
28
+ * Namely, schema of the type system that is currently executing,
29
+ * and the fragments defined in the query document
30
+ */
31
+ export interface ExecutionContext {
32
+ schema: GraphQLSchema;
33
+ fragments: ObjMap<FragmentDefinitionNode>;
34
+ rootValue: unknown;
35
+ contextValue: unknown;
36
+ operation: OperationDefinitionNode;
37
+ variableValues: {
38
+ [variable: string]: unknown;
39
+ };
40
+ fieldResolver: GraphQLFieldResolver<any, any>;
41
+ typeResolver: GraphQLTypeResolver<any, any>;
42
+ subscribeFieldResolver: GraphQLFieldResolver<any, any>;
43
+ errors: Array<GraphQLError>;
44
+ }
45
+ /**
46
+ * The result of GraphQL execution.
47
+ *
48
+ * - `errors` is included when any errors occurred as a non-empty array.
49
+ * - `data` is the result of a successful execution of the query.
50
+ * - `extensions` is reserved for adding non-standard properties.
51
+ */
52
+ export interface ExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
53
+ errors?: ReadonlyArray<GraphQLError>;
54
+ data?: TData | null;
55
+ extensions?: TExtensions;
56
+ }
57
+ export interface FormattedExecutionResult<TData = ObjMap<unknown>, TExtensions = ObjMap<unknown>> {
58
+ errors?: ReadonlyArray<GraphQLFormattedError>;
59
+ data?: TData | null;
60
+ extensions?: TExtensions;
61
+ }
62
+ export interface ExecutionArgs {
63
+ schema: GraphQLSchema;
64
+ document: DocumentNode;
65
+ rootValue?: unknown;
66
+ contextValue?: unknown;
67
+ variableValues?: Maybe<{
68
+ readonly [variable: string]: unknown;
69
+ }>;
70
+ operationName?: Maybe<string>;
71
+ fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
72
+ typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
73
+ subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
74
+ }
75
+ /**
76
+ * Implements the "Executing requests" section of the GraphQL specification.
77
+ *
78
+ * Returns either a synchronous ExecutionResult (if all encountered resolvers
79
+ * are synchronous), or a Promise of an ExecutionResult that will eventually be
80
+ * resolved and never rejected.
81
+ *
82
+ * If the arguments to this function do not result in a legal execution context,
83
+ * a GraphQLError will be thrown immediately explaining the invalid input.
84
+ */
85
+ export declare function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult>;
86
+ /**
87
+ * Also implements the "Executing requests" section of the GraphQL specification.
88
+ * However, it guarantees to complete synchronously (or throw an error) assuming
89
+ * that all field resolvers are also synchronous.
90
+ */
91
+ export declare function executeSync(args: ExecutionArgs): ExecutionResult;
92
+ /**
93
+ * Essential assertions before executing to provide developer feedback for
94
+ * improper use of the GraphQL library.
95
+ *
96
+ * @internal
97
+ */
98
+ export declare function assertValidExecutionArguments(schema: GraphQLSchema, document: DocumentNode, rawVariableValues: Maybe<{
99
+ readonly [variable: string]: unknown;
100
+ }>): void;
101
+ /**
102
+ * Constructs a ExecutionContext object from the arguments passed to
103
+ * execute, which we will pass throughout the other execution methods.
104
+ *
105
+ * Throws a GraphQLError if a valid execution context cannot be created.
106
+ *
107
+ * TODO: consider no longer exporting this function
108
+ * @internal
109
+ */
110
+ export declare function buildExecutionContext(args: ExecutionArgs): ReadonlyArray<GraphQLError> | ExecutionContext;
111
+ /**
112
+ * TODO: consider no longer exporting this function
113
+ * @internal
114
+ */
115
+ export declare function buildResolveInfo(exeContext: ExecutionContext, fieldDef: GraphQLField<unknown, unknown>, fieldNodes: ReadonlyArray<FieldNode>, parentType: GraphQLObjectType, path: Path): GraphQLResolveInfo;
116
+ /**
117
+ * If a resolveType function is not given, then a default resolve behavior is
118
+ * used which attempts two strategies:
119
+ *
120
+ * First, See if the provided value has a `__typename` field defined, if so, use
121
+ * that value as name of the resolved type.
122
+ *
123
+ * Otherwise, test each possible type for the abstract type by calling
124
+ * isTypeOf for the object being coerced, returning the first type that matches.
125
+ */
126
+ export declare const defaultTypeResolver: GraphQLTypeResolver<unknown, unknown>;
127
+ /**
128
+ * If a resolve function is not given, then a default resolve behavior is used
129
+ * which takes the property of the source object of the same name as the field
130
+ * and returns it as the result, or if it's a function, returns the result
131
+ * of calling that function while passing along args and context value.
132
+ */
133
+ export declare const defaultFieldResolver: GraphQLFieldResolver<unknown, unknown>;
134
+ /**
135
+ * Implements the "Subscribe" algorithm described in the GraphQL specification.
136
+ *
137
+ * Returns a Promise which resolves to either an AsyncIterator (if successful)
138
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
139
+ * other arguments to this function are invalid, or if the resolved event stream
140
+ * is not an async iterable.
141
+ *
142
+ * If the client-provided arguments to this function do not result in a
143
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
144
+ * descriptive errors and no data will be returned.
145
+ *
146
+ * If the source stream could not be created due to faulty subscription
147
+ * resolver logic or underlying systems, the promise will resolve to a single
148
+ * ExecutionResult containing `errors` and no `data`.
149
+ *
150
+ * If the operation succeeded, the promise resolves to an AsyncIterator, which
151
+ * yields a stream of ExecutionResults representing the response stream.
152
+ *
153
+ * Accepts either an object with named arguments, or individual arguments.
154
+ */
155
+ export declare function subscribe(args: ExecutionArgs): PromiseOrValue<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult>;
156
+ /**
157
+ * Implements the "CreateSourceEventStream" algorithm described in the
158
+ * GraphQL specification, resolving the subscription source event stream.
159
+ *
160
+ * Returns a Promise which resolves to either an AsyncIterable (if successful)
161
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
162
+ * other arguments to this function are invalid, or if the resolved event stream
163
+ * is not an async iterable.
164
+ *
165
+ * If the client-provided arguments to this function do not result in a
166
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
167
+ * descriptive errors and no data will be returned.
168
+ *
169
+ * If the the source stream could not be created due to faulty subscription
170
+ * resolver logic or underlying systems, the promise will resolve to a single
171
+ * ExecutionResult containing `errors` and no `data`.
172
+ *
173
+ * If the operation succeeded, the promise resolves to the AsyncIterable for the
174
+ * event stream returned by the resolver.
175
+ *
176
+ * A Source Event Stream represents a sequence of events, each of which triggers
177
+ * a GraphQL execution for that event.
178
+ *
179
+ * This may be useful when hosting the stateful subscription service in a
180
+ * different process or machine than the stateless GraphQL execution engine,
181
+ * or otherwise separating these two steps. For more on this, see the
182
+ * "Supporting Subscriptions at Scale" information in the GraphQL specification.
183
+ */
184
+ export declare function createSourceEventStream(args: ExecutionArgs): PromiseOrValue<AsyncIterable<unknown> | ExecutionResult>;
185
+ /**
186
+ * This method looks up the field on the given type definition.
187
+ * It has special casing for the three introspection fields,
188
+ * __schema, __type and __typename. __typename is special because
189
+ * it can always be queried as a field, even in situations where no
190
+ * other fields are allowed, like on a Union. __schema and __type
191
+ * could get automatically added to the query type, but that would
192
+ * require mutating type definitions, which would cause issues.
193
+ *
194
+ * @internal
195
+ */
196
+ export declare function getFieldDef(schema: GraphQLSchema, parentType: GraphQLObjectType, fieldNode: FieldNode): Maybe<GraphQLField<unknown, unknown>>;
@@ -0,0 +1,5 @@
1
+ export * from './collectFields.cjs';
2
+ export * from './execute.cjs';
3
+ export * from './mapAsyncIterator.cjs';
4
+ export * from './values.cjs';
5
+ export { pathToArray as responsePathAsArray } from 'graphql/jsutils/Path.cjs';
@@ -0,0 +1,5 @@
1
+ export * from './collectFields.js';
2
+ export * from './execute.js';
3
+ export * from './mapAsyncIterator.js';
4
+ export * from './values.js';
5
+ export { pathToArray as responsePathAsArray } from 'graphql/jsutils/Path.js';
@@ -0,0 +1,6 @@
1
+ import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue.cjs';
2
+ /**
3
+ * Given an AsyncIterable and a callback function, return an AsyncIterator
4
+ * which produces values mapped via calling the callback function.
5
+ */
6
+ export declare function mapAsyncIterator<T, U, R = undefined>(iterable: AsyncGenerator<T, R, void> | AsyncIterable<T>, callback: (value: T) => PromiseOrValue<U>): AsyncGenerator<U, R, void>;
@@ -0,0 +1,6 @@
1
+ import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue.js';
2
+ /**
3
+ * Given an AsyncIterable and a callback function, return an AsyncIterator
4
+ * which produces values mapped via calling the callback function.
5
+ */
6
+ export declare function mapAsyncIterator<T, U, R = undefined>(iterable: AsyncGenerator<T, R, void> | AsyncIterable<T>, callback: (value: T) => PromiseOrValue<U>): AsyncGenerator<U, R, void>;
@@ -0,0 +1,56 @@
1
+ import { DocumentNode, GraphQLFieldResolver, GraphQLSchema } from 'graphql';
2
+ import type { Maybe } from 'graphql/jsutils/Maybe.cjs';
3
+ import type { ExecutionArgs, ExecutionResult } from './execute.cjs';
4
+ /**
5
+ * Implements the "Subscribe" algorithm described in the GraphQL specification.
6
+ *
7
+ * Returns a Promise which resolves to either an AsyncIterator (if successful)
8
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
9
+ * other arguments to this function are invalid, or if the resolved event stream
10
+ * is not an async iterable.
11
+ *
12
+ * If the client-provided arguments to this function do not result in a
13
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
14
+ * descriptive errors and no data will be returned.
15
+ *
16
+ * If the source stream could not be created due to faulty subscription
17
+ * resolver logic or underlying systems, the promise will resolve to a single
18
+ * ExecutionResult containing `errors` and no `data`.
19
+ *
20
+ * If the operation succeeded, the promise resolves to an AsyncIterator, which
21
+ * yields a stream of ExecutionResults representing the response stream.
22
+ *
23
+ * Accepts either an object with named arguments, or individual arguments.
24
+ */
25
+ export declare function subscribe(args: ExecutionArgs): Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult>;
26
+ /**
27
+ * Implements the "CreateSourceEventStream" algorithm described in the
28
+ * GraphQL specification, resolving the subscription source event stream.
29
+ *
30
+ * Returns a Promise which resolves to either an AsyncIterable (if successful)
31
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
32
+ * other arguments to this function are invalid, or if the resolved event stream
33
+ * is not an async iterable.
34
+ *
35
+ * If the client-provided arguments to this function do not result in a
36
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
37
+ * descriptive errors and no data will be returned.
38
+ *
39
+ * If the the source stream could not be created due to faulty subscription
40
+ * resolver logic or underlying systems, the promise will resolve to a single
41
+ * ExecutionResult containing `errors` and no `data`.
42
+ *
43
+ * If the operation succeeded, the promise resolves to the AsyncIterable for the
44
+ * event stream returned by the resolver.
45
+ *
46
+ * A Source Event Stream represents a sequence of events, each of which triggers
47
+ * a GraphQL execution for that event.
48
+ *
49
+ * This may be useful when hosting the stateful subscription service in a
50
+ * different process or machine than the stateless GraphQL execution engine,
51
+ * or otherwise separating these two steps. For more on this, see the
52
+ * "Supporting Subscriptions at Scale" information in the GraphQL specification.
53
+ */
54
+ export declare function createSourceEventStream(schema: GraphQLSchema, document: DocumentNode, rootValue?: unknown, contextValue?: unknown, variableValues?: Maybe<{
55
+ readonly [variable: string]: unknown;
56
+ }>, operationName?: Maybe<string>, subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>): Promise<AsyncIterable<unknown> | ExecutionResult>;
@@ -0,0 +1,56 @@
1
+ import { DocumentNode, GraphQLFieldResolver, GraphQLSchema } from 'graphql';
2
+ import type { Maybe } from 'graphql/jsutils/Maybe.js';
3
+ import type { ExecutionArgs, ExecutionResult } from './execute.js';
4
+ /**
5
+ * Implements the "Subscribe" algorithm described in the GraphQL specification.
6
+ *
7
+ * Returns a Promise which resolves to either an AsyncIterator (if successful)
8
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
9
+ * other arguments to this function are invalid, or if the resolved event stream
10
+ * is not an async iterable.
11
+ *
12
+ * If the client-provided arguments to this function do not result in a
13
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
14
+ * descriptive errors and no data will be returned.
15
+ *
16
+ * If the source stream could not be created due to faulty subscription
17
+ * resolver logic or underlying systems, the promise will resolve to a single
18
+ * ExecutionResult containing `errors` and no `data`.
19
+ *
20
+ * If the operation succeeded, the promise resolves to an AsyncIterator, which
21
+ * yields a stream of ExecutionResults representing the response stream.
22
+ *
23
+ * Accepts either an object with named arguments, or individual arguments.
24
+ */
25
+ export declare function subscribe(args: ExecutionArgs): Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult>;
26
+ /**
27
+ * Implements the "CreateSourceEventStream" algorithm described in the
28
+ * GraphQL specification, resolving the subscription source event stream.
29
+ *
30
+ * Returns a Promise which resolves to either an AsyncIterable (if successful)
31
+ * or an ExecutionResult (error). The promise will be rejected if the schema or
32
+ * other arguments to this function are invalid, or if the resolved event stream
33
+ * is not an async iterable.
34
+ *
35
+ * If the client-provided arguments to this function do not result in a
36
+ * compliant subscription, a GraphQL Response (ExecutionResult) with
37
+ * descriptive errors and no data will be returned.
38
+ *
39
+ * If the the source stream could not be created due to faulty subscription
40
+ * resolver logic or underlying systems, the promise will resolve to a single
41
+ * ExecutionResult containing `errors` and no `data`.
42
+ *
43
+ * If the operation succeeded, the promise resolves to the AsyncIterable for the
44
+ * event stream returned by the resolver.
45
+ *
46
+ * A Source Event Stream represents a sequence of events, each of which triggers
47
+ * a GraphQL execution for that event.
48
+ *
49
+ * This may be useful when hosting the stateful subscription service in a
50
+ * different process or machine than the stateless GraphQL execution engine,
51
+ * or otherwise separating these two steps. For more on this, see the
52
+ * "Supporting Subscriptions at Scale" information in the GraphQL specification.
53
+ */
54
+ export declare function createSourceEventStream(schema: GraphQLSchema, document: DocumentNode, rootValue?: unknown, contextValue?: unknown, variableValues?: Maybe<{
55
+ readonly [variable: string]: unknown;
56
+ }>, operationName?: Maybe<string>, subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>): Promise<AsyncIterable<unknown> | ExecutionResult>;
@@ -0,0 +1,54 @@
1
+ import type { Maybe } from 'graphql/jsutils/Maybe.cjs';
2
+ import type { ObjMap } from 'graphql/jsutils/ObjMap.cjs';
3
+ import { GraphQLError, DirectiveNode, FieldNode, VariableDefinitionNode, GraphQLField, GraphQLDirective, GraphQLSchema } from 'graphql';
4
+ declare type CoercedVariableValues = {
5
+ errors: ReadonlyArray<GraphQLError>;
6
+ coerced?: never;
7
+ } | {
8
+ coerced: {
9
+ [variable: string]: unknown;
10
+ };
11
+ errors?: never;
12
+ };
13
+ /**
14
+ * Prepares an object map of variableValues of the correct type based on the
15
+ * provided variable definitions and arbitrary input. If the input cannot be
16
+ * parsed to match the variable definitions, a GraphQLError will be thrown.
17
+ *
18
+ * Note: The returned value is a plain Object with a prototype, since it is
19
+ * exposed to user code. Care should be taken to not pull values from the
20
+ * Object prototype.
21
+ */
22
+ export declare function getVariableValues(schema: GraphQLSchema, varDefNodes: ReadonlyArray<VariableDefinitionNode>, inputs: {
23
+ readonly [variable: string]: unknown;
24
+ }, options?: {
25
+ maxErrors?: number;
26
+ }): CoercedVariableValues;
27
+ /**
28
+ * Prepares an object map of argument values given a list of argument
29
+ * definitions and list of argument AST nodes.
30
+ *
31
+ * Note: The returned value is a plain Object with a prototype, since it is
32
+ * exposed to user code. Care should be taken to not pull values from the
33
+ * Object prototype.
34
+ */
35
+ export declare function getArgumentValues(def: GraphQLField<unknown, unknown> | GraphQLDirective, node: FieldNode | DirectiveNode, variableValues?: Maybe<ObjMap<unknown>>): {
36
+ [argument: string]: unknown;
37
+ };
38
+ /**
39
+ * Prepares an object map of argument values given a directive definition
40
+ * and a AST node which may contain directives. Optionally also accepts a map
41
+ * of variable values.
42
+ *
43
+ * If the directive does not exist on the node, returns undefined.
44
+ *
45
+ * Note: The returned value is a plain Object with a prototype, since it is
46
+ * exposed to user code. Care should be taken to not pull values from the
47
+ * Object prototype.
48
+ */
49
+ export declare function getDirectiveValues(directiveDef: GraphQLDirective, node: {
50
+ readonly directives?: ReadonlyArray<DirectiveNode>;
51
+ }, variableValues?: Maybe<ObjMap<unknown>>): undefined | {
52
+ [argument: string]: unknown;
53
+ };
54
+ export {};
@@ -0,0 +1,54 @@
1
+ import type { Maybe } from 'graphql/jsutils/Maybe.js';
2
+ import type { ObjMap } from 'graphql/jsutils/ObjMap.js';
3
+ import { GraphQLError, DirectiveNode, FieldNode, VariableDefinitionNode, GraphQLField, GraphQLDirective, GraphQLSchema } from 'graphql';
4
+ declare type CoercedVariableValues = {
5
+ errors: ReadonlyArray<GraphQLError>;
6
+ coerced?: never;
7
+ } | {
8
+ coerced: {
9
+ [variable: string]: unknown;
10
+ };
11
+ errors?: never;
12
+ };
13
+ /**
14
+ * Prepares an object map of variableValues of the correct type based on the
15
+ * provided variable definitions and arbitrary input. If the input cannot be
16
+ * parsed to match the variable definitions, a GraphQLError will be thrown.
17
+ *
18
+ * Note: The returned value is a plain Object with a prototype, since it is
19
+ * exposed to user code. Care should be taken to not pull values from the
20
+ * Object prototype.
21
+ */
22
+ export declare function getVariableValues(schema: GraphQLSchema, varDefNodes: ReadonlyArray<VariableDefinitionNode>, inputs: {
23
+ readonly [variable: string]: unknown;
24
+ }, options?: {
25
+ maxErrors?: number;
26
+ }): CoercedVariableValues;
27
+ /**
28
+ * Prepares an object map of argument values given a list of argument
29
+ * definitions and list of argument AST nodes.
30
+ *
31
+ * Note: The returned value is a plain Object with a prototype, since it is
32
+ * exposed to user code. Care should be taken to not pull values from the
33
+ * Object prototype.
34
+ */
35
+ export declare function getArgumentValues(def: GraphQLField<unknown, unknown> | GraphQLDirective, node: FieldNode | DirectiveNode, variableValues?: Maybe<ObjMap<unknown>>): {
36
+ [argument: string]: unknown;
37
+ };
38
+ /**
39
+ * Prepares an object map of argument values given a directive definition
40
+ * and a AST node which may contain directives. Optionally also accepts a map
41
+ * of variable values.
42
+ *
43
+ * If the directive does not exist on the node, returns undefined.
44
+ *
45
+ * Note: The returned value is a plain Object with a prototype, since it is
46
+ * exposed to user code. Care should be taken to not pull values from the
47
+ * Object prototype.
48
+ */
49
+ export declare function getDirectiveValues(directiveDef: GraphQLDirective, node: {
50
+ readonly directives?: ReadonlyArray<DirectiveNode>;
51
+ }, variableValues?: Maybe<ObjMap<unknown>>): undefined | {
52
+ [argument: string]: unknown;
53
+ };
54
+ export {};
@@ -0,0 +1 @@
1
+ export * from './execution/index.cjs';
@@ -0,0 +1 @@
1
+ export * from './execution/index.js';