@graphql-tools/executor 2.0.0-alpha-20240709212042-9a70c086fa543c594055305622a600bb95343b42 → 2.0.0-alpha-20240804112853-812acba5ea59541106a53f872874fd7aebcffcfc
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/IncrementalGraph.js +42 -43
- package/cjs/execution/IncrementalPublisher.js +17 -17
- package/cjs/execution/{buildFieldPlan.js → buildExecutionPlan.js} +29 -42
- package/cjs/execution/execute.js +148 -114
- package/cjs/execution/types.js +17 -17
- package/esm/execution/IncrementalGraph.js +43 -44
- package/esm/execution/IncrementalPublisher.js +18 -18
- package/esm/execution/{buildFieldPlan.js → buildExecutionPlan.js} +26 -39
- package/esm/execution/execute.js +147 -113
- package/esm/execution/types.js +13 -13
- package/package.json +2 -2
- package/typings/execution/IncrementalGraph.d.cts +6 -7
- package/typings/execution/IncrementalGraph.d.ts +6 -7
- package/typings/execution/buildExecutionPlan.d.cts +8 -0
- package/typings/execution/buildExecutionPlan.d.ts +8 -0
- package/typings/execution/execute.d.cts +3 -1
- package/typings/execution/execute.d.ts +3 -1
- package/typings/execution/types.d.cts +22 -22
- package/typings/execution/types.d.ts +22 -22
- package/typings/execution/buildFieldPlan.d.cts +0 -8
- package/typings/execution/buildFieldPlan.d.ts +0 -8
|
@@ -1,6 +1,7 @@
|
|
|
1
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
|
+
import { AccumulatorMap } from './AccumulatorMap.js';
|
|
4
5
|
import { CancellableStreamRecord, IncrementalDataRecord, IncrementalExecutionResults, InitialIncrementalExecutionResult, SingularExecutionResult, SubsequentIncrementalExecutionResult } from './types.js';
|
|
5
6
|
/**
|
|
6
7
|
* Terminology
|
|
@@ -43,7 +44,7 @@ export interface ExecutionContext<TVariables = any, TContext = any> {
|
|
|
43
44
|
sendPathAndLabelOnIncremental: boolean;
|
|
44
45
|
errorWithIncrementalSubscription: boolean;
|
|
45
46
|
signal: AbortSignal | undefined;
|
|
46
|
-
errors:
|
|
47
|
+
errors: AccumulatorMap<Path | undefined, GraphQLError> | undefined;
|
|
47
48
|
cancellableStreams: Set<CancellableStreamRecord> | undefined;
|
|
48
49
|
incrementalDataRecords: Array<IncrementalDataRecord> | undefined;
|
|
49
50
|
}
|
|
@@ -106,6 +107,7 @@ export declare function buildExecutionContext<TData = any, TVariables = any, TCo
|
|
|
106
107
|
* @internal
|
|
107
108
|
*/
|
|
108
109
|
export declare function buildResolveInfo(exeContext: ExecutionContext, fieldDef: GraphQLField<unknown, unknown>, fieldNodes: Array<FieldNode>, parentType: GraphQLObjectType, path: Path): GraphQLResolveInfo;
|
|
110
|
+
export declare const CRITICAL_ERROR: "CRITICAL_ERROR";
|
|
109
111
|
/**
|
|
110
112
|
* If a resolveType function is not given, then a default resolve behavior is
|
|
111
113
|
* used which attempts two strategies:
|
|
@@ -50,7 +50,7 @@ export interface FormattedSubsequentIncrementalExecutionResult<TData = unknown,
|
|
|
50
50
|
completed?: ReadonlyArray<FormattedCompletedResult>;
|
|
51
51
|
extensions?: TExtensions;
|
|
52
52
|
}
|
|
53
|
-
interface
|
|
53
|
+
interface ExecutionGroupResult<TData = Record<string, unknown>> {
|
|
54
54
|
errors?: ReadonlyArray<GraphQLError>;
|
|
55
55
|
data: TData;
|
|
56
56
|
}
|
|
@@ -72,7 +72,7 @@ export interface FormattedIncrementalDeferResult<TData = Record<string, unknown>
|
|
|
72
72
|
subPath?: ReadonlyArray<string | number>;
|
|
73
73
|
extensions?: TExtensions;
|
|
74
74
|
}
|
|
75
|
-
interface
|
|
75
|
+
interface StreamItemsRecordResult<TData = ReadonlyArray<unknown>> {
|
|
76
76
|
errors?: ReadonlyArray<GraphQLError>;
|
|
77
77
|
items: TData;
|
|
78
78
|
}
|
|
@@ -108,45 +108,45 @@ export interface FormattedCompletedResult {
|
|
|
108
108
|
label?: string;
|
|
109
109
|
errors?: ReadonlyArray<GraphQLError>;
|
|
110
110
|
}
|
|
111
|
-
export declare function
|
|
112
|
-
export type
|
|
113
|
-
export declare function
|
|
114
|
-
export interface
|
|
115
|
-
|
|
111
|
+
export declare function isPendingExecutionGroup(incrementalDataRecord: IncrementalDataRecord): incrementalDataRecord is PendingExecutionGroup;
|
|
112
|
+
export type CompletedExecutionGroup = SuccessfulExecutionGroup | FailedExecutionGroup;
|
|
113
|
+
export declare function isCompletedExecutionGroup(incrementalDataRecordResult: IncrementalDataRecordResult): incrementalDataRecordResult is CompletedExecutionGroup;
|
|
114
|
+
export interface SuccessfulExecutionGroup {
|
|
115
|
+
pendingExecutionGroup: PendingExecutionGroup;
|
|
116
116
|
path: Array<string | number>;
|
|
117
|
-
result:
|
|
117
|
+
result: ExecutionGroupResult;
|
|
118
118
|
incrementalDataRecords: ReadonlyArray<IncrementalDataRecord> | undefined;
|
|
119
119
|
errors?: never;
|
|
120
120
|
}
|
|
121
|
-
interface
|
|
122
|
-
|
|
121
|
+
interface FailedExecutionGroup {
|
|
122
|
+
pendingExecutionGroup: PendingExecutionGroup;
|
|
123
123
|
path: Array<string | number>;
|
|
124
124
|
errors: ReadonlyArray<GraphQLError>;
|
|
125
125
|
result?: never;
|
|
126
126
|
}
|
|
127
|
-
export declare function
|
|
128
|
-
export interface
|
|
127
|
+
export declare function isFailedExecutionGroup(completedExecutionGroup: CompletedExecutionGroup): completedExecutionGroup is FailedExecutionGroup;
|
|
128
|
+
export interface PendingExecutionGroup {
|
|
129
129
|
path: Path | undefined;
|
|
130
130
|
deferredFragmentRecords: ReadonlyArray<DeferredFragmentRecord>;
|
|
131
|
-
result: BoxedPromiseOrValue<
|
|
131
|
+
result: BoxedPromiseOrValue<CompletedExecutionGroup> | (() => BoxedPromiseOrValue<CompletedExecutionGroup>);
|
|
132
132
|
}
|
|
133
|
-
export type
|
|
133
|
+
export type DeliveryGroup = DeferredFragmentRecord | StreamRecord;
|
|
134
134
|
/** @internal */
|
|
135
135
|
export declare class DeferredFragmentRecord {
|
|
136
136
|
path: Path | undefined;
|
|
137
137
|
label: string | undefined;
|
|
138
138
|
id?: string | undefined;
|
|
139
139
|
parent: DeferredFragmentRecord | undefined;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
children: Set<
|
|
140
|
+
pendingExecutionGroups: Set<PendingExecutionGroup>;
|
|
141
|
+
successfulExecutionGroups: Set<SuccessfulExecutionGroup>;
|
|
142
|
+
children: Set<DeliveryGroup>;
|
|
143
143
|
pending: boolean;
|
|
144
144
|
fns: Array<() => void>;
|
|
145
145
|
constructor(path: Path | undefined, label: string | undefined, parent: DeferredFragmentRecord | undefined);
|
|
146
146
|
onPending(fn: () => void): void;
|
|
147
147
|
setAsPending(): void;
|
|
148
148
|
}
|
|
149
|
-
export declare function isDeferredFragmentRecord(
|
|
149
|
+
export declare function isDeferredFragmentRecord(deliveryGroup: DeliveryGroup): deliveryGroup is DeferredFragmentRecord;
|
|
150
150
|
export interface StreamItemResult {
|
|
151
151
|
path: Path;
|
|
152
152
|
item?: unknown;
|
|
@@ -163,14 +163,14 @@ export interface StreamRecord {
|
|
|
163
163
|
}
|
|
164
164
|
export interface StreamItemsResult {
|
|
165
165
|
streamRecord: StreamRecord;
|
|
166
|
-
result?:
|
|
166
|
+
result?: StreamItemsRecordResult | undefined;
|
|
167
167
|
incrementalDataRecords?: ReadonlyArray<IncrementalDataRecord> | undefined;
|
|
168
168
|
errors?: ReadonlyArray<GraphQLError> | undefined;
|
|
169
169
|
}
|
|
170
170
|
export interface CancellableStreamRecord extends StreamRecord {
|
|
171
171
|
earlyReturn: () => Promise<unknown>;
|
|
172
172
|
}
|
|
173
|
-
export declare function isCancellableStreamRecord(
|
|
174
|
-
export type IncrementalDataRecord =
|
|
175
|
-
export type IncrementalDataRecordResult =
|
|
173
|
+
export declare function isCancellableStreamRecord(deliveryGroup: DeliveryGroup): deliveryGroup is CancellableStreamRecord;
|
|
174
|
+
export type IncrementalDataRecord = PendingExecutionGroup | StreamRecord;
|
|
175
|
+
export type IncrementalDataRecordResult = CompletedExecutionGroup | StreamItemsResult;
|
|
176
176
|
export {};
|
|
@@ -50,7 +50,7 @@ export interface FormattedSubsequentIncrementalExecutionResult<TData = unknown,
|
|
|
50
50
|
completed?: ReadonlyArray<FormattedCompletedResult>;
|
|
51
51
|
extensions?: TExtensions;
|
|
52
52
|
}
|
|
53
|
-
interface
|
|
53
|
+
interface ExecutionGroupResult<TData = Record<string, unknown>> {
|
|
54
54
|
errors?: ReadonlyArray<GraphQLError>;
|
|
55
55
|
data: TData;
|
|
56
56
|
}
|
|
@@ -72,7 +72,7 @@ export interface FormattedIncrementalDeferResult<TData = Record<string, unknown>
|
|
|
72
72
|
subPath?: ReadonlyArray<string | number>;
|
|
73
73
|
extensions?: TExtensions;
|
|
74
74
|
}
|
|
75
|
-
interface
|
|
75
|
+
interface StreamItemsRecordResult<TData = ReadonlyArray<unknown>> {
|
|
76
76
|
errors?: ReadonlyArray<GraphQLError>;
|
|
77
77
|
items: TData;
|
|
78
78
|
}
|
|
@@ -108,45 +108,45 @@ export interface FormattedCompletedResult {
|
|
|
108
108
|
label?: string;
|
|
109
109
|
errors?: ReadonlyArray<GraphQLError>;
|
|
110
110
|
}
|
|
111
|
-
export declare function
|
|
112
|
-
export type
|
|
113
|
-
export declare function
|
|
114
|
-
export interface
|
|
115
|
-
|
|
111
|
+
export declare function isPendingExecutionGroup(incrementalDataRecord: IncrementalDataRecord): incrementalDataRecord is PendingExecutionGroup;
|
|
112
|
+
export type CompletedExecutionGroup = SuccessfulExecutionGroup | FailedExecutionGroup;
|
|
113
|
+
export declare function isCompletedExecutionGroup(incrementalDataRecordResult: IncrementalDataRecordResult): incrementalDataRecordResult is CompletedExecutionGroup;
|
|
114
|
+
export interface SuccessfulExecutionGroup {
|
|
115
|
+
pendingExecutionGroup: PendingExecutionGroup;
|
|
116
116
|
path: Array<string | number>;
|
|
117
|
-
result:
|
|
117
|
+
result: ExecutionGroupResult;
|
|
118
118
|
incrementalDataRecords: ReadonlyArray<IncrementalDataRecord> | undefined;
|
|
119
119
|
errors?: never;
|
|
120
120
|
}
|
|
121
|
-
interface
|
|
122
|
-
|
|
121
|
+
interface FailedExecutionGroup {
|
|
122
|
+
pendingExecutionGroup: PendingExecutionGroup;
|
|
123
123
|
path: Array<string | number>;
|
|
124
124
|
errors: ReadonlyArray<GraphQLError>;
|
|
125
125
|
result?: never;
|
|
126
126
|
}
|
|
127
|
-
export declare function
|
|
128
|
-
export interface
|
|
127
|
+
export declare function isFailedExecutionGroup(completedExecutionGroup: CompletedExecutionGroup): completedExecutionGroup is FailedExecutionGroup;
|
|
128
|
+
export interface PendingExecutionGroup {
|
|
129
129
|
path: Path | undefined;
|
|
130
130
|
deferredFragmentRecords: ReadonlyArray<DeferredFragmentRecord>;
|
|
131
|
-
result: BoxedPromiseOrValue<
|
|
131
|
+
result: BoxedPromiseOrValue<CompletedExecutionGroup> | (() => BoxedPromiseOrValue<CompletedExecutionGroup>);
|
|
132
132
|
}
|
|
133
|
-
export type
|
|
133
|
+
export type DeliveryGroup = DeferredFragmentRecord | StreamRecord;
|
|
134
134
|
/** @internal */
|
|
135
135
|
export declare class DeferredFragmentRecord {
|
|
136
136
|
path: Path | undefined;
|
|
137
137
|
label: string | undefined;
|
|
138
138
|
id?: string | undefined;
|
|
139
139
|
parent: DeferredFragmentRecord | undefined;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
children: Set<
|
|
140
|
+
pendingExecutionGroups: Set<PendingExecutionGroup>;
|
|
141
|
+
successfulExecutionGroups: Set<SuccessfulExecutionGroup>;
|
|
142
|
+
children: Set<DeliveryGroup>;
|
|
143
143
|
pending: boolean;
|
|
144
144
|
fns: Array<() => void>;
|
|
145
145
|
constructor(path: Path | undefined, label: string | undefined, parent: DeferredFragmentRecord | undefined);
|
|
146
146
|
onPending(fn: () => void): void;
|
|
147
147
|
setAsPending(): void;
|
|
148
148
|
}
|
|
149
|
-
export declare function isDeferredFragmentRecord(
|
|
149
|
+
export declare function isDeferredFragmentRecord(deliveryGroup: DeliveryGroup): deliveryGroup is DeferredFragmentRecord;
|
|
150
150
|
export interface StreamItemResult {
|
|
151
151
|
path: Path;
|
|
152
152
|
item?: unknown;
|
|
@@ -163,14 +163,14 @@ export interface StreamRecord {
|
|
|
163
163
|
}
|
|
164
164
|
export interface StreamItemsResult {
|
|
165
165
|
streamRecord: StreamRecord;
|
|
166
|
-
result?:
|
|
166
|
+
result?: StreamItemsRecordResult | undefined;
|
|
167
167
|
incrementalDataRecords?: ReadonlyArray<IncrementalDataRecord> | undefined;
|
|
168
168
|
errors?: ReadonlyArray<GraphQLError> | undefined;
|
|
169
169
|
}
|
|
170
170
|
export interface CancellableStreamRecord extends StreamRecord {
|
|
171
171
|
earlyReturn: () => Promise<unknown>;
|
|
172
172
|
}
|
|
173
|
-
export declare function isCancellableStreamRecord(
|
|
174
|
-
export type IncrementalDataRecord =
|
|
175
|
-
export type IncrementalDataRecordResult =
|
|
173
|
+
export declare function isCancellableStreamRecord(deliveryGroup: DeliveryGroup): deliveryGroup is CancellableStreamRecord;
|
|
174
|
+
export type IncrementalDataRecord = PendingExecutionGroup | StreamRecord;
|
|
175
|
+
export type IncrementalDataRecordResult = CompletedExecutionGroup | StreamItemsResult;
|
|
176
176
|
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
|
8
|
-
export declare function buildBranchingFieldPlan(originalGroupedFieldSet: GroupedFieldSet, parentDeferUsages?: DeferUsageSet): FieldPlan;
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
|
8
|
-
export declare function buildBranchingFieldPlan(originalGroupedFieldSet: GroupedFieldSet, parentDeferUsages?: DeferUsageSet): FieldPlan;
|