@graphql-tools/executor 1.2.6 → 2.0.0-alpha-20240606221026-cd2a4fabe51906319f8dc07745f98f37ffbcbdee
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.
- package/cjs/execution/AccumulatorMap.js +21 -0
- package/cjs/execution/BoxedPromiseOrValue.js +25 -0
- package/cjs/execution/IncrementalGraph.js +271 -0
- package/cjs/execution/IncrementalPublisher.js +274 -0
- package/cjs/execution/buildFieldPlan.js +62 -0
- package/cjs/execution/collectFields.js +174 -0
- package/cjs/execution/execute.js +548 -513
- package/cjs/execution/getBySet.js +13 -0
- package/cjs/execution/isSameSet.js +15 -0
- package/cjs/execution/promiseWithResolvers.js +18 -0
- package/cjs/execution/types.js +19 -0
- package/esm/execution/AccumulatorMap.js +17 -0
- package/esm/execution/BoxedPromiseOrValue.js +21 -0
- package/esm/execution/IncrementalGraph.js +267 -0
- package/esm/execution/IncrementalPublisher.js +270 -0
- package/esm/execution/buildFieldPlan.js +58 -0
- package/esm/execution/collectFields.js +169 -0
- package/esm/execution/execute.js +549 -514
- package/esm/execution/getBySet.js +9 -0
- package/esm/execution/isSameSet.js +11 -0
- package/esm/execution/promiseWithResolvers.js +14 -0
- package/esm/execution/types.js +12 -0
- package/package.json +2 -2
- package/typings/execution/AccumulatorMap.d.cts +7 -0
- package/typings/execution/AccumulatorMap.d.ts +7 -0
- package/typings/execution/BoxedPromiseOrValue.d.cts +15 -0
- package/typings/execution/BoxedPromiseOrValue.d.ts +15 -0
- package/typings/execution/IncrementalGraph.d.cts +32 -0
- package/typings/execution/IncrementalGraph.d.ts +32 -0
- package/typings/execution/IncrementalPublisher.d.cts +8 -0
- package/typings/execution/IncrementalPublisher.d.ts +8 -0
- package/typings/execution/buildFieldPlan.d.cts +7 -0
- package/typings/execution/buildFieldPlan.d.ts +7 -0
- package/typings/execution/collectFields.d.cts +40 -0
- package/typings/execution/collectFields.d.ts +40 -0
- package/typings/execution/execute.d.cts +8 -106
- package/typings/execution/execute.d.ts +8 -106
- package/typings/execution/getBySet.d.cts +1 -0
- package/typings/execution/getBySet.d.ts +1 -0
- package/typings/execution/isSameSet.d.cts +1 -0
- package/typings/execution/isSameSet.d.ts +1 -0
- package/typings/execution/promiseWithResolvers.d.cts +10 -0
- package/typings/execution/promiseWithResolvers.d.ts +10 -0
- package/typings/execution/types.d.cts +155 -0
- package/typings/execution/types.d.ts +155 -0
- package/cjs/execution/flattenAsyncIterable.js +0 -89
- package/esm/execution/flattenAsyncIterable.js +0 -85
- package/typings/execution/flattenAsyncIterable.d.cts +0 -7
- package/typings/execution/flattenAsyncIterable.d.ts +0 -7
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on Promise.withResolvers proposal
|
|
3
|
+
* https://github.com/tc39/proposal-promise-with-resolvers
|
|
4
|
+
*/
|
|
5
|
+
export function promiseWithResolvers() {
|
|
6
|
+
// these are assigned synchronously within the Promise constructor
|
|
7
|
+
let resolve;
|
|
8
|
+
let reject;
|
|
9
|
+
const promise = new Promise((res, rej) => {
|
|
10
|
+
resolve = res;
|
|
11
|
+
reject = rej;
|
|
12
|
+
});
|
|
13
|
+
return { promise, resolve, reject };
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function isDeferredGroupedFieldSetRecord(incrementalDataRecord) {
|
|
2
|
+
return 'deferredFragmentRecords' in incrementalDataRecord;
|
|
3
|
+
}
|
|
4
|
+
export function isDeferredGroupedFieldSetResult(subsequentResult) {
|
|
5
|
+
return 'deferredGroupedFieldSetRecord' in subsequentResult;
|
|
6
|
+
}
|
|
7
|
+
export function isNonReconcilableDeferredGroupedFieldSetResult(deferredGroupedFieldSetResult) {
|
|
8
|
+
return deferredGroupedFieldSetResult.errors !== undefined;
|
|
9
|
+
}
|
|
10
|
+
export function isCancellableStreamRecord(subsequentResultRecord) {
|
|
11
|
+
return 'earlyReturn' in subsequentResultRecord;
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/executor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha-20240606221026-cd2a4fabe51906319f8dc07745f98f37ffbcbdee",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-tools/utils": "
|
|
9
|
+
"@graphql-tools/utils": "10.3.0-alpha-20240606221026-cd2a4fabe51906319f8dc07745f98f37ffbcbdee",
|
|
10
10
|
"@graphql-typed-document-node/core": "3.2.0",
|
|
11
11
|
"@repeaterjs/repeater": "^3.0.4",
|
|
12
12
|
"tslib": "^2.4.0",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MaybePromise } from '@graphql-tools/utils';
|
|
2
|
+
/**
|
|
3
|
+
* A BoxedPromiseOrValue is a container for a value or promise where the value
|
|
4
|
+
* will be updated when the promise resolves.
|
|
5
|
+
*
|
|
6
|
+
* A BoxedPromiseOrValue may only be used with promises whose possible
|
|
7
|
+
* rejection has already been handled, otherwise this will lead to unhandled
|
|
8
|
+
* promise rejections.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
* */
|
|
12
|
+
export declare class BoxedPromiseOrValue<T> {
|
|
13
|
+
value: MaybePromise<T>;
|
|
14
|
+
constructor(value: MaybePromise<T>);
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MaybePromise } from '@graphql-tools/utils';
|
|
2
|
+
/**
|
|
3
|
+
* A BoxedPromiseOrValue is a container for a value or promise where the value
|
|
4
|
+
* will be updated when the promise resolves.
|
|
5
|
+
*
|
|
6
|
+
* A BoxedPromiseOrValue may only be used with promises whose possible
|
|
7
|
+
* rejection has already been handled, otherwise this will lead to unhandled
|
|
8
|
+
* promise rejections.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
* */
|
|
12
|
+
export declare class BoxedPromiseOrValue<T> {
|
|
13
|
+
value: MaybePromise<T>;
|
|
14
|
+
constructor(value: MaybePromise<T>);
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DeferredFragmentRecord, IncrementalDataRecord, IncrementalDataRecordResult, ReconcilableDeferredGroupedFieldSetResult, StreamRecord, SubsequentResultRecord } from './types.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare class IncrementalGraph {
|
|
6
|
+
private _pending;
|
|
7
|
+
private _deferredFragmentNodes;
|
|
8
|
+
private _newPending;
|
|
9
|
+
private _newIncrementalDataRecords;
|
|
10
|
+
private _completedQueue;
|
|
11
|
+
private _nextQueue;
|
|
12
|
+
constructor();
|
|
13
|
+
addIncrementalDataRecords(incrementalDataRecords: ReadonlyArray<IncrementalDataRecord>): void;
|
|
14
|
+
addCompletedReconcilableDeferredGroupedFieldSet(reconcilableResult: ReconcilableDeferredGroupedFieldSetResult): void;
|
|
15
|
+
getNewPending(): ReadonlyArray<SubsequentResultRecord>;
|
|
16
|
+
completedIncrementalData(): {
|
|
17
|
+
[Symbol.asyncIterator](): any;
|
|
18
|
+
next: () => Promise<IteratorResult<Iterable<IncrementalDataRecordResult>>>;
|
|
19
|
+
return: () => Promise<IteratorResult<Iterable<IncrementalDataRecordResult>>>;
|
|
20
|
+
};
|
|
21
|
+
hasNext(): boolean;
|
|
22
|
+
completeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord): Array<ReconcilableDeferredGroupedFieldSetResult> | undefined;
|
|
23
|
+
removeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord): boolean;
|
|
24
|
+
removeStream(streamRecord: StreamRecord): void;
|
|
25
|
+
private _removePending;
|
|
26
|
+
private _addDeferredGroupedFieldSetRecord;
|
|
27
|
+
private _addStreamRecord;
|
|
28
|
+
private _addDeferredFragmentNode;
|
|
29
|
+
private _onStreamItems;
|
|
30
|
+
private _yieldCurrentCompletedIncrementalData;
|
|
31
|
+
private _enqueue;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DeferredFragmentRecord, IncrementalDataRecord, IncrementalDataRecordResult, ReconcilableDeferredGroupedFieldSetResult, StreamRecord, SubsequentResultRecord } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare class IncrementalGraph {
|
|
6
|
+
private _pending;
|
|
7
|
+
private _deferredFragmentNodes;
|
|
8
|
+
private _newPending;
|
|
9
|
+
private _newIncrementalDataRecords;
|
|
10
|
+
private _completedQueue;
|
|
11
|
+
private _nextQueue;
|
|
12
|
+
constructor();
|
|
13
|
+
addIncrementalDataRecords(incrementalDataRecords: ReadonlyArray<IncrementalDataRecord>): void;
|
|
14
|
+
addCompletedReconcilableDeferredGroupedFieldSet(reconcilableResult: ReconcilableDeferredGroupedFieldSetResult): void;
|
|
15
|
+
getNewPending(): ReadonlyArray<SubsequentResultRecord>;
|
|
16
|
+
completedIncrementalData(): {
|
|
17
|
+
[Symbol.asyncIterator](): any;
|
|
18
|
+
next: () => Promise<IteratorResult<Iterable<IncrementalDataRecordResult>>>;
|
|
19
|
+
return: () => Promise<IteratorResult<Iterable<IncrementalDataRecordResult>>>;
|
|
20
|
+
};
|
|
21
|
+
hasNext(): boolean;
|
|
22
|
+
completeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord): Array<ReconcilableDeferredGroupedFieldSetResult> | undefined;
|
|
23
|
+
removeDeferredFragment(deferredFragmentRecord: DeferredFragmentRecord): boolean;
|
|
24
|
+
removeStream(streamRecord: StreamRecord): void;
|
|
25
|
+
private _removePending;
|
|
26
|
+
private _addDeferredGroupedFieldSetRecord;
|
|
27
|
+
private _addStreamRecord;
|
|
28
|
+
private _addDeferredFragmentNode;
|
|
29
|
+
private _onStreamItems;
|
|
30
|
+
private _yieldCurrentCompletedIncrementalData;
|
|
31
|
+
private _enqueue;
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GraphQLError } from 'graphql';
|
|
2
|
+
import type { CancellableStreamRecord, IncrementalDataRecord, IncrementalExecutionResults } from './types.cjs';
|
|
3
|
+
export declare function buildIncrementalResponse<TData = any>(context: IncrementalPublisherContext, result: TData, errors: ReadonlyArray<GraphQLError> | undefined, incrementalDataRecords: ReadonlyArray<IncrementalDataRecord>): IncrementalExecutionResults<TData>;
|
|
4
|
+
interface IncrementalPublisherContext {
|
|
5
|
+
signal: AbortSignal | undefined;
|
|
6
|
+
cancellableStreams: Set<CancellableStreamRecord> | undefined;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GraphQLError } from 'graphql';
|
|
2
|
+
import type { CancellableStreamRecord, IncrementalDataRecord, IncrementalExecutionResults } from './types.js';
|
|
3
|
+
export declare function buildIncrementalResponse<TData = any>(context: IncrementalPublisherContext, result: TData, errors: ReadonlyArray<GraphQLError> | undefined, incrementalDataRecords: ReadonlyArray<IncrementalDataRecord>): IncrementalExecutionResults<TData>;
|
|
4
|
+
interface IncrementalPublisherContext {
|
|
5
|
+
signal: AbortSignal | undefined;
|
|
6
|
+
cancellableStreams: Set<CancellableStreamRecord> | undefined;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeferUsage, GroupedFieldSet } from './collectFields.cjs';
|
|
2
|
+
export type DeferUsageSet = ReadonlySet<DeferUsage>;
|
|
3
|
+
export interface FieldPlan {
|
|
4
|
+
groupedFieldSet: GroupedFieldSet;
|
|
5
|
+
newGroupedFieldSets: Map<DeferUsageSet, GroupedFieldSet>;
|
|
6
|
+
}
|
|
7
|
+
export declare function buildFieldPlan(originalGroupedFieldSet: GroupedFieldSet, parentDeferUsages?: DeferUsageSet): FieldPlan;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeferUsage, GroupedFieldSet } from './collectFields.js';
|
|
2
|
+
export type DeferUsageSet = ReadonlySet<DeferUsage>;
|
|
3
|
+
export interface FieldPlan {
|
|
4
|
+
groupedFieldSet: GroupedFieldSet;
|
|
5
|
+
newGroupedFieldSets: Map<DeferUsageSet, GroupedFieldSet>;
|
|
6
|
+
}
|
|
7
|
+
export declare function buildFieldPlan(originalGroupedFieldSet: GroupedFieldSet, parentDeferUsages?: DeferUsageSet): FieldPlan;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FieldNode, FragmentDefinitionNode, GraphQLObjectType, GraphQLSchema, OperationDefinitionNode } from 'graphql';
|
|
2
|
+
export interface DeferUsage {
|
|
3
|
+
label: string | undefined;
|
|
4
|
+
parentDeferUsage: DeferUsage | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface FieldDetails {
|
|
7
|
+
node: FieldNode;
|
|
8
|
+
deferUsage: DeferUsage | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type FieldGroup = ReadonlyArray<FieldDetails>;
|
|
11
|
+
export type GroupedFieldSet = ReadonlyMap<string, FieldGroup>;
|
|
12
|
+
/**
|
|
13
|
+
* Given a selectionSet, collects all of the fields and returns them.
|
|
14
|
+
*
|
|
15
|
+
* CollectFields requires the "runtime type" of an object. For a field that
|
|
16
|
+
* returns an Interface or Union type, the "runtime type" will be the actual
|
|
17
|
+
* object type returned by that field.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectFields<TVariables = any>(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: TVariables, runtimeType: GraphQLObjectType, operation: OperationDefinitionNode): {
|
|
22
|
+
groupedFieldSet: GroupedFieldSet;
|
|
23
|
+
newDeferUsages: ReadonlyArray<DeferUsage>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Given an array of field nodes, collects all of the subfields of the passed
|
|
27
|
+
* in fields, and returns them at the end.
|
|
28
|
+
*
|
|
29
|
+
* CollectSubFields requires the "return type" of an object. For a field that
|
|
30
|
+
* returns an Interface or Union type, the "return type" will be the actual
|
|
31
|
+
* object type returned by that field.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function collectSubfields(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: {
|
|
36
|
+
[variable: string]: unknown;
|
|
37
|
+
}, operation: OperationDefinitionNode, returnType: GraphQLObjectType, fieldGroup: FieldGroup): {
|
|
38
|
+
groupedFieldSet: GroupedFieldSet;
|
|
39
|
+
newDeferUsages: ReadonlyArray<DeferUsage>;
|
|
40
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FieldNode, FragmentDefinitionNode, GraphQLObjectType, GraphQLSchema, OperationDefinitionNode } from 'graphql';
|
|
2
|
+
export interface DeferUsage {
|
|
3
|
+
label: string | undefined;
|
|
4
|
+
parentDeferUsage: DeferUsage | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface FieldDetails {
|
|
7
|
+
node: FieldNode;
|
|
8
|
+
deferUsage: DeferUsage | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type FieldGroup = ReadonlyArray<FieldDetails>;
|
|
11
|
+
export type GroupedFieldSet = ReadonlyMap<string, FieldGroup>;
|
|
12
|
+
/**
|
|
13
|
+
* Given a selectionSet, collects all of the fields and returns them.
|
|
14
|
+
*
|
|
15
|
+
* CollectFields requires the "runtime type" of an object. For a field that
|
|
16
|
+
* returns an Interface or Union type, the "runtime type" will be the actual
|
|
17
|
+
* object type returned by that field.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectFields<TVariables = any>(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: TVariables, runtimeType: GraphQLObjectType, operation: OperationDefinitionNode): {
|
|
22
|
+
groupedFieldSet: GroupedFieldSet;
|
|
23
|
+
newDeferUsages: ReadonlyArray<DeferUsage>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Given an array of field nodes, collects all of the subfields of the passed
|
|
27
|
+
* in fields, and returns them at the end.
|
|
28
|
+
*
|
|
29
|
+
* CollectSubFields requires the "return type" of an object. For a field that
|
|
30
|
+
* returns an Interface or Union type, the "return type" will be the actual
|
|
31
|
+
* object type returned by that field.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function collectSubfields(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: {
|
|
36
|
+
[variable: string]: unknown;
|
|
37
|
+
}, operation: OperationDefinitionNode, returnType: GraphQLObjectType, fieldGroup: FieldGroup): {
|
|
38
|
+
groupedFieldSet: GroupedFieldSet;
|
|
39
|
+
newDeferUsages: ReadonlyArray<DeferUsage>;
|
|
40
|
+
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver,
|
|
1
|
+
import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLObjectType, GraphQLResolveInfo, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
|
|
2
2
|
import { Maybe, MaybePromise, Path } from '@graphql-tools/utils';
|
|
3
3
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
4
|
-
|
|
5
|
-
errors?: ReadonlyArray<GraphQLError>;
|
|
6
|
-
data?: TData | null;
|
|
7
|
-
extensions?: TExtensions;
|
|
8
|
-
}
|
|
4
|
+
import { CancellableStreamRecord, IncrementalDataRecord, IncrementalExecutionResults, InitialIncrementalExecutionResult, SingularExecutionResult, SubsequentIncrementalExecutionResult } from './types.cjs';
|
|
9
5
|
/**
|
|
10
6
|
* Terminology
|
|
11
7
|
*
|
|
@@ -41,63 +37,12 @@ export interface ExecutionContext<TVariables = any, TContext = any> {
|
|
|
41
37
|
fieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
42
38
|
typeResolver: GraphQLTypeResolver<any, TContext>;
|
|
43
39
|
subscribeFieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
errors?: ReadonlyArray<GraphQLFormattedError>;
|
|
50
|
-
data?: TData | null;
|
|
51
|
-
extensions?: TExtensions;
|
|
52
|
-
}
|
|
53
|
-
export interface IncrementalExecutionResults<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> {
|
|
54
|
-
initialResult: InitialIncrementalExecutionResult<TData, TExtensions>;
|
|
55
|
-
subsequentResults: AsyncGenerator<SubsequentIncrementalExecutionResult<TData, TExtensions>, void, void>;
|
|
56
|
-
}
|
|
57
|
-
export interface InitialIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends SingularExecutionResult<TData, TExtensions> {
|
|
58
|
-
hasNext: boolean;
|
|
59
|
-
incremental?: ReadonlyArray<IncrementalResult<TData, TExtensions>>;
|
|
60
|
-
extensions?: TExtensions;
|
|
61
|
-
}
|
|
62
|
-
export interface FormattedInitialIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends FormattedExecutionResult<TData, TExtensions> {
|
|
63
|
-
hasNext: boolean;
|
|
64
|
-
incremental?: ReadonlyArray<FormattedIncrementalResult<TData, TExtensions>>;
|
|
65
|
-
extensions?: TExtensions;
|
|
66
|
-
}
|
|
67
|
-
export interface SubsequentIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> {
|
|
68
|
-
hasNext: boolean;
|
|
69
|
-
incremental?: ReadonlyArray<IncrementalResult<TData, TExtensions>>;
|
|
70
|
-
extensions?: TExtensions;
|
|
40
|
+
enableEarlyExecution: boolean;
|
|
41
|
+
signal: AbortSignal | undefined;
|
|
42
|
+
errors: Map<Path | undefined, GraphQLError> | undefined;
|
|
43
|
+
cancellableStreams: Set<CancellableStreamRecord> | undefined;
|
|
44
|
+
incrementalDataRecords: Array<IncrementalDataRecord> | undefined;
|
|
71
45
|
}
|
|
72
|
-
export interface FormattedSubsequentIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> {
|
|
73
|
-
hasNext: boolean;
|
|
74
|
-
incremental?: ReadonlyArray<FormattedIncrementalResult<TData, TExtensions>>;
|
|
75
|
-
extensions?: TExtensions;
|
|
76
|
-
}
|
|
77
|
-
export interface IncrementalDeferResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends SingularExecutionResult<TData, TExtensions> {
|
|
78
|
-
path?: ReadonlyArray<string | number>;
|
|
79
|
-
label?: string;
|
|
80
|
-
}
|
|
81
|
-
export interface FormattedIncrementalDeferResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends FormattedExecutionResult<TData, TExtensions> {
|
|
82
|
-
path?: ReadonlyArray<string | number>;
|
|
83
|
-
label?: string;
|
|
84
|
-
}
|
|
85
|
-
export interface IncrementalStreamResult<TData = Array<unknown>, TExtensions = Record<string, unknown>> {
|
|
86
|
-
errors?: ReadonlyArray<GraphQLError>;
|
|
87
|
-
items?: TData | null;
|
|
88
|
-
path?: ReadonlyArray<string | number>;
|
|
89
|
-
label?: string;
|
|
90
|
-
extensions?: TExtensions;
|
|
91
|
-
}
|
|
92
|
-
export interface FormattedIncrementalStreamResult<TData = Array<unknown>, TExtensions = Record<string, unknown>> {
|
|
93
|
-
errors?: ReadonlyArray<GraphQLFormattedError>;
|
|
94
|
-
items?: TData | null;
|
|
95
|
-
path?: ReadonlyArray<string | number>;
|
|
96
|
-
label?: string;
|
|
97
|
-
extensions?: TExtensions;
|
|
98
|
-
}
|
|
99
|
-
export type IncrementalResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = IncrementalDeferResult<TData, TExtensions> | IncrementalStreamResult<TData, TExtensions>;
|
|
100
|
-
export type FormattedIncrementalResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = FormattedIncrementalDeferResult<TData, TExtensions> | FormattedIncrementalStreamResult<TData, TExtensions>;
|
|
101
46
|
export interface ExecutionArgs<TData = any, TVariables = any, TContext = any> {
|
|
102
47
|
schema: GraphQLSchema;
|
|
103
48
|
document: TypedDocumentNode<TData, TVariables>;
|
|
@@ -108,6 +53,7 @@ export interface ExecutionArgs<TData = any, TVariables = any, TContext = any> {
|
|
|
108
53
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, TContext>>;
|
|
109
54
|
typeResolver?: Maybe<GraphQLTypeResolver<any, TContext>>;
|
|
110
55
|
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, TContext>>;
|
|
56
|
+
enableEarlyExecution?: Maybe<boolean>;
|
|
111
57
|
signal?: AbortSignal;
|
|
112
58
|
}
|
|
113
59
|
/**
|
|
@@ -205,49 +151,6 @@ export declare const defaultFieldResolver: GraphQLFieldResolver<unknown, unknown
|
|
|
205
151
|
*/
|
|
206
152
|
export declare function subscribe<TData = any, TVariables = any, TContext = any>(args: ExecutionArgs<TData, TVariables, TContext>): MaybePromise<AsyncGenerator<SingularExecutionResult<TData> | InitialIncrementalExecutionResult<TData> | SubsequentIncrementalExecutionResult<TData>, void, void> | SingularExecutionResult<TData>>;
|
|
207
153
|
export declare function flattenIncrementalResults<TData>(incrementalResults: IncrementalExecutionResults<TData>): AsyncGenerator<SubsequentIncrementalExecutionResult<TData, Record<string, unknown>>, void, void>;
|
|
208
|
-
declare class DeferredFragmentRecord {
|
|
209
|
-
type: 'defer';
|
|
210
|
-
errors: Array<GraphQLError>;
|
|
211
|
-
label: string | undefined;
|
|
212
|
-
path: Array<string | number>;
|
|
213
|
-
promise: Promise<void>;
|
|
214
|
-
data: Record<string, unknown> | null;
|
|
215
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
216
|
-
isCompleted: boolean;
|
|
217
|
-
_exeContext: ExecutionContext;
|
|
218
|
-
_resolve?: (arg: MaybePromise<Record<string, unknown> | null>) => void;
|
|
219
|
-
constructor(opts: {
|
|
220
|
-
label: string | undefined;
|
|
221
|
-
path: Path | undefined;
|
|
222
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
223
|
-
exeContext: ExecutionContext;
|
|
224
|
-
});
|
|
225
|
-
addData(data: MaybePromise<Record<string, unknown> | null>): void;
|
|
226
|
-
}
|
|
227
|
-
declare class StreamRecord {
|
|
228
|
-
type: 'stream';
|
|
229
|
-
errors: Array<GraphQLError>;
|
|
230
|
-
label: string | undefined;
|
|
231
|
-
path: Array<string | number>;
|
|
232
|
-
items: Array<unknown> | null;
|
|
233
|
-
promise: Promise<void>;
|
|
234
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
235
|
-
iterator: AsyncIterator<unknown> | undefined;
|
|
236
|
-
isCompletedIterator?: boolean;
|
|
237
|
-
isCompleted: boolean;
|
|
238
|
-
_exeContext: ExecutionContext;
|
|
239
|
-
_resolve?: (arg: MaybePromise<Array<unknown> | null>) => void;
|
|
240
|
-
constructor(opts: {
|
|
241
|
-
label: string | undefined;
|
|
242
|
-
path: Path | undefined;
|
|
243
|
-
iterator?: AsyncIterator<unknown>;
|
|
244
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
245
|
-
exeContext: ExecutionContext;
|
|
246
|
-
});
|
|
247
|
-
addItems(items: MaybePromise<Array<unknown> | null>): void;
|
|
248
|
-
setIsCompletedIterator(): void;
|
|
249
|
-
}
|
|
250
|
-
type AsyncPayloadRecord = DeferredFragmentRecord | StreamRecord;
|
|
251
154
|
/**
|
|
252
155
|
* This method looks up the field on the given type definition.
|
|
253
156
|
* It has special casing for the three introspection fields,
|
|
@@ -261,4 +164,3 @@ type AsyncPayloadRecord = DeferredFragmentRecord | StreamRecord;
|
|
|
261
164
|
*/
|
|
262
165
|
export declare function getFieldDef(schema: GraphQLSchema, parentType: GraphQLObjectType, fieldNode: FieldNode): Maybe<GraphQLField<unknown, unknown>>;
|
|
263
166
|
export declare function isIncrementalResult<TData>(result: SingularExecutionResult<TData> | IncrementalExecutionResults<TData>): result is IncrementalExecutionResults<TData>;
|
|
264
|
-
export {};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver,
|
|
1
|
+
import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLObjectType, GraphQLResolveInfo, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
|
|
2
2
|
import { Maybe, MaybePromise, Path } from '@graphql-tools/utils';
|
|
3
3
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
4
|
-
|
|
5
|
-
errors?: ReadonlyArray<GraphQLError>;
|
|
6
|
-
data?: TData | null;
|
|
7
|
-
extensions?: TExtensions;
|
|
8
|
-
}
|
|
4
|
+
import { CancellableStreamRecord, IncrementalDataRecord, IncrementalExecutionResults, InitialIncrementalExecutionResult, SingularExecutionResult, SubsequentIncrementalExecutionResult } from './types.js';
|
|
9
5
|
/**
|
|
10
6
|
* Terminology
|
|
11
7
|
*
|
|
@@ -41,63 +37,12 @@ export interface ExecutionContext<TVariables = any, TContext = any> {
|
|
|
41
37
|
fieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
42
38
|
typeResolver: GraphQLTypeResolver<any, TContext>;
|
|
43
39
|
subscribeFieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
errors?: ReadonlyArray<GraphQLFormattedError>;
|
|
50
|
-
data?: TData | null;
|
|
51
|
-
extensions?: TExtensions;
|
|
52
|
-
}
|
|
53
|
-
export interface IncrementalExecutionResults<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> {
|
|
54
|
-
initialResult: InitialIncrementalExecutionResult<TData, TExtensions>;
|
|
55
|
-
subsequentResults: AsyncGenerator<SubsequentIncrementalExecutionResult<TData, TExtensions>, void, void>;
|
|
56
|
-
}
|
|
57
|
-
export interface InitialIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends SingularExecutionResult<TData, TExtensions> {
|
|
58
|
-
hasNext: boolean;
|
|
59
|
-
incremental?: ReadonlyArray<IncrementalResult<TData, TExtensions>>;
|
|
60
|
-
extensions?: TExtensions;
|
|
61
|
-
}
|
|
62
|
-
export interface FormattedInitialIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends FormattedExecutionResult<TData, TExtensions> {
|
|
63
|
-
hasNext: boolean;
|
|
64
|
-
incremental?: ReadonlyArray<FormattedIncrementalResult<TData, TExtensions>>;
|
|
65
|
-
extensions?: TExtensions;
|
|
66
|
-
}
|
|
67
|
-
export interface SubsequentIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> {
|
|
68
|
-
hasNext: boolean;
|
|
69
|
-
incremental?: ReadonlyArray<IncrementalResult<TData, TExtensions>>;
|
|
70
|
-
extensions?: TExtensions;
|
|
40
|
+
enableEarlyExecution: boolean;
|
|
41
|
+
signal: AbortSignal | undefined;
|
|
42
|
+
errors: Map<Path | undefined, GraphQLError> | undefined;
|
|
43
|
+
cancellableStreams: Set<CancellableStreamRecord> | undefined;
|
|
44
|
+
incrementalDataRecords: Array<IncrementalDataRecord> | undefined;
|
|
71
45
|
}
|
|
72
|
-
export interface FormattedSubsequentIncrementalExecutionResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> {
|
|
73
|
-
hasNext: boolean;
|
|
74
|
-
incremental?: ReadonlyArray<FormattedIncrementalResult<TData, TExtensions>>;
|
|
75
|
-
extensions?: TExtensions;
|
|
76
|
-
}
|
|
77
|
-
export interface IncrementalDeferResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends SingularExecutionResult<TData, TExtensions> {
|
|
78
|
-
path?: ReadonlyArray<string | number>;
|
|
79
|
-
label?: string;
|
|
80
|
-
}
|
|
81
|
-
export interface FormattedIncrementalDeferResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> extends FormattedExecutionResult<TData, TExtensions> {
|
|
82
|
-
path?: ReadonlyArray<string | number>;
|
|
83
|
-
label?: string;
|
|
84
|
-
}
|
|
85
|
-
export interface IncrementalStreamResult<TData = Array<unknown>, TExtensions = Record<string, unknown>> {
|
|
86
|
-
errors?: ReadonlyArray<GraphQLError>;
|
|
87
|
-
items?: TData | null;
|
|
88
|
-
path?: ReadonlyArray<string | number>;
|
|
89
|
-
label?: string;
|
|
90
|
-
extensions?: TExtensions;
|
|
91
|
-
}
|
|
92
|
-
export interface FormattedIncrementalStreamResult<TData = Array<unknown>, TExtensions = Record<string, unknown>> {
|
|
93
|
-
errors?: ReadonlyArray<GraphQLFormattedError>;
|
|
94
|
-
items?: TData | null;
|
|
95
|
-
path?: ReadonlyArray<string | number>;
|
|
96
|
-
label?: string;
|
|
97
|
-
extensions?: TExtensions;
|
|
98
|
-
}
|
|
99
|
-
export type IncrementalResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = IncrementalDeferResult<TData, TExtensions> | IncrementalStreamResult<TData, TExtensions>;
|
|
100
|
-
export type FormattedIncrementalResult<TData = Record<string, unknown>, TExtensions = Record<string, unknown>> = FormattedIncrementalDeferResult<TData, TExtensions> | FormattedIncrementalStreamResult<TData, TExtensions>;
|
|
101
46
|
export interface ExecutionArgs<TData = any, TVariables = any, TContext = any> {
|
|
102
47
|
schema: GraphQLSchema;
|
|
103
48
|
document: TypedDocumentNode<TData, TVariables>;
|
|
@@ -108,6 +53,7 @@ export interface ExecutionArgs<TData = any, TVariables = any, TContext = any> {
|
|
|
108
53
|
fieldResolver?: Maybe<GraphQLFieldResolver<any, TContext>>;
|
|
109
54
|
typeResolver?: Maybe<GraphQLTypeResolver<any, TContext>>;
|
|
110
55
|
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, TContext>>;
|
|
56
|
+
enableEarlyExecution?: Maybe<boolean>;
|
|
111
57
|
signal?: AbortSignal;
|
|
112
58
|
}
|
|
113
59
|
/**
|
|
@@ -205,49 +151,6 @@ export declare const defaultFieldResolver: GraphQLFieldResolver<unknown, unknown
|
|
|
205
151
|
*/
|
|
206
152
|
export declare function subscribe<TData = any, TVariables = any, TContext = any>(args: ExecutionArgs<TData, TVariables, TContext>): MaybePromise<AsyncGenerator<SingularExecutionResult<TData> | InitialIncrementalExecutionResult<TData> | SubsequentIncrementalExecutionResult<TData>, void, void> | SingularExecutionResult<TData>>;
|
|
207
153
|
export declare function flattenIncrementalResults<TData>(incrementalResults: IncrementalExecutionResults<TData>): AsyncGenerator<SubsequentIncrementalExecutionResult<TData, Record<string, unknown>>, void, void>;
|
|
208
|
-
declare class DeferredFragmentRecord {
|
|
209
|
-
type: 'defer';
|
|
210
|
-
errors: Array<GraphQLError>;
|
|
211
|
-
label: string | undefined;
|
|
212
|
-
path: Array<string | number>;
|
|
213
|
-
promise: Promise<void>;
|
|
214
|
-
data: Record<string, unknown> | null;
|
|
215
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
216
|
-
isCompleted: boolean;
|
|
217
|
-
_exeContext: ExecutionContext;
|
|
218
|
-
_resolve?: (arg: MaybePromise<Record<string, unknown> | null>) => void;
|
|
219
|
-
constructor(opts: {
|
|
220
|
-
label: string | undefined;
|
|
221
|
-
path: Path | undefined;
|
|
222
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
223
|
-
exeContext: ExecutionContext;
|
|
224
|
-
});
|
|
225
|
-
addData(data: MaybePromise<Record<string, unknown> | null>): void;
|
|
226
|
-
}
|
|
227
|
-
declare class StreamRecord {
|
|
228
|
-
type: 'stream';
|
|
229
|
-
errors: Array<GraphQLError>;
|
|
230
|
-
label: string | undefined;
|
|
231
|
-
path: Array<string | number>;
|
|
232
|
-
items: Array<unknown> | null;
|
|
233
|
-
promise: Promise<void>;
|
|
234
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
235
|
-
iterator: AsyncIterator<unknown> | undefined;
|
|
236
|
-
isCompletedIterator?: boolean;
|
|
237
|
-
isCompleted: boolean;
|
|
238
|
-
_exeContext: ExecutionContext;
|
|
239
|
-
_resolve?: (arg: MaybePromise<Array<unknown> | null>) => void;
|
|
240
|
-
constructor(opts: {
|
|
241
|
-
label: string | undefined;
|
|
242
|
-
path: Path | undefined;
|
|
243
|
-
iterator?: AsyncIterator<unknown>;
|
|
244
|
-
parentContext: AsyncPayloadRecord | undefined;
|
|
245
|
-
exeContext: ExecutionContext;
|
|
246
|
-
});
|
|
247
|
-
addItems(items: MaybePromise<Array<unknown> | null>): void;
|
|
248
|
-
setIsCompletedIterator(): void;
|
|
249
|
-
}
|
|
250
|
-
type AsyncPayloadRecord = DeferredFragmentRecord | StreamRecord;
|
|
251
154
|
/**
|
|
252
155
|
* This method looks up the field on the given type definition.
|
|
253
156
|
* It has special casing for the three introspection fields,
|
|
@@ -261,4 +164,3 @@ type AsyncPayloadRecord = DeferredFragmentRecord | StreamRecord;
|
|
|
261
164
|
*/
|
|
262
165
|
export declare function getFieldDef(schema: GraphQLSchema, parentType: GraphQLObjectType, fieldNode: FieldNode): Maybe<GraphQLField<unknown, unknown>>;
|
|
263
166
|
export declare function isIncrementalResult<TData>(result: SingularExecutionResult<TData> | IncrementalExecutionResults<TData>): result is IncrementalExecutionResults<TData>;
|
|
264
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getBySet<T, U>(map: ReadonlyMap<ReadonlySet<T>, U>, setToMatch: ReadonlySet<T>): U | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getBySet<T, U>(map: ReadonlyMap<ReadonlySet<T>, U>, setToMatch: ReadonlySet<T>): U | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isSameSet<T>(setA: ReadonlySet<T>, setB: ReadonlySet<T>): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isSameSet<T>(setA: ReadonlySet<T>, setB: ReadonlySet<T>): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MaybePromise } from '@graphql-tools/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Based on Promise.withResolvers proposal
|
|
4
|
+
* https://github.com/tc39/proposal-promise-with-resolvers
|
|
5
|
+
*/
|
|
6
|
+
export declare function promiseWithResolvers<T>(): {
|
|
7
|
+
promise: Promise<T>;
|
|
8
|
+
resolve: (value: T | MaybePromise<T>) => void;
|
|
9
|
+
reject: (reason?: any) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MaybePromise } from '@graphql-tools/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Based on Promise.withResolvers proposal
|
|
4
|
+
* https://github.com/tc39/proposal-promise-with-resolvers
|
|
5
|
+
*/
|
|
6
|
+
export declare function promiseWithResolvers<T>(): {
|
|
7
|
+
promise: Promise<T>;
|
|
8
|
+
resolve: (value: T | MaybePromise<T>) => void;
|
|
9
|
+
reject: (reason?: any) => void;
|
|
10
|
+
};
|