@@ -6,14 +6,17 @@ import { memoize1 } from '../../jsutils/memoize1.js';
66import { memoize2 } from '../../jsutils/memoize2.js' ;
77import type { ObjMap } from '../../jsutils/ObjMap.js' ;
88
9- import type { GraphQLError } from '../../error/GraphQLError.js' ;
9+ import type {
10+ GraphQLError ,
11+ GraphQLFormattedError ,
12+ } from '../../error/GraphQLError.js' ;
1013
1114import type {
1215 DeferUsage ,
1316 FieldDetails ,
1417 GroupedFieldSet ,
1518} from '../collectFields.js' ;
16- import type { ExecutionResult } from '../Executor.js' ;
19+ import type { ExecutionResult , FormattedExecutionResult } from '../Executor.js' ;
1720import type {
1821 DeferUsageSet ,
1922 ExecutionPlan ,
@@ -22,51 +25,70 @@ import { IncrementalExecutor } from '../incremental/IncrementalExecutor.js';
2225
2326import { BranchingIncrementalPublisher } from './BranchingIncrementalPublisher.js' ;
2427
25- export interface ExperimentalIncrementalExecutionResults {
26- initialResult : InitialIncrementalExecutionResult ;
28+ export interface LegacyExperimentalIncrementalExecutionResults <
29+ TInitialData = ObjMap < unknown > ,
30+ TDeferredData = ObjMap < unknown > ,
31+ TStreamItem = unknown ,
32+ TExtensions = ObjMap < unknown > ,
33+ > {
34+ initialResult : LegacyInitialIncrementalExecutionResult <
35+ TInitialData ,
36+ TExtensions
37+ > ;
2738 subsequentResults : AsyncGenerator <
28- SubsequentIncrementalExecutionResult ,
39+ LegacySubsequentIncrementalExecutionResult <
40+ TDeferredData ,
41+ TStreamItem ,
42+ TExtensions
43+ > ,
2944 void ,
3045 void
3146 > ;
3247}
3348
34- export interface InitialIncrementalExecutionResult <
35- TData = ObjMap < unknown > ,
49+ export interface LegacyInitialIncrementalExecutionResult <
50+ TInitialData = ObjMap < unknown > ,
3651 TExtensions = ObjMap < unknown > ,
37- > extends ExecutionResult < TData , TExtensions > {
38- data : TData ;
52+ > extends ExecutionResult < TInitialData , TExtensions > {
53+ data : TInitialData ;
3954 hasNext : true ;
4055 extensions ?: TExtensions ;
4156}
4257
43- export interface SubsequentIncrementalExecutionResult <
44- TData = unknown ,
58+ export interface LegacySubsequentIncrementalExecutionResult <
59+ TDeferredData = ObjMap < unknown > ,
60+ TStreamItem = unknown ,
4561 TExtensions = ObjMap < unknown > ,
4662> {
47- incremental ?: ReadonlyArray < IncrementalResult < TData , TExtensions > > ;
63+ incremental ?: ReadonlyArray <
64+ LegacyIncrementalResult < TDeferredData , TStreamItem , TExtensions >
65+ > ;
4866 hasNext : boolean ;
4967 extensions ?: TExtensions ;
5068}
5169
52- export type IncrementalResult < TData = unknown , TExtensions = ObjMap < unknown > > =
53- | IncrementalDeferResult < TData , TExtensions >
54- | IncrementalStreamResult < TData , TExtensions > ;
70+ export type LegacyIncrementalResult <
71+ TDeferredData = ObjMap < unknown > ,
72+ TStreamItem = unknown ,
73+ TExtensions = ObjMap < unknown > ,
74+ > =
75+ | LegacyIncrementalDeferResult < TDeferredData , TExtensions >
76+ | LegacyIncrementalStreamResult < TStreamItem , TExtensions > ;
5577
56- export interface IncrementalDeferResult <
57- TData = ObjMap < unknown > ,
78+ export interface LegacyIncrementalDeferResult <
79+ TDeferredData = ObjMap < unknown > ,
5880 TExtensions = ObjMap < unknown > ,
59- > extends ExecutionResult < TData , TExtensions > {
81+ > extends ExecutionResult < TDeferredData , TExtensions > {
6082 path : ReadonlyArray < string | number > ;
6183 label ?: string ;
6284}
6385
64- export interface IncrementalStreamResult <
65- TData = ReadonlyArray < unknown > ,
86+ export interface LegacyIncrementalStreamResult <
87+ TStreamItem = unknown ,
6688 TExtensions = ObjMap < unknown > ,
6789> {
6890 errors ?: ReadonlyArray < GraphQLError > ;
69- items : TData | null ;
91+ items : ReadonlyArray < TStreamItem > | null ;
7092 path : ReadonlyArray < string | number > ;
7193 label ?: string ;
7294 extensions ?: TExtensions ;
@@ -82,11 +104,79 @@ const buildBranchingExecutionPlanFromDeferred = memoize2(
82104 buildBranchingExecutionPlan ( groupedFieldSet , deferUsageSet ) ,
83105) ;
84106
107+ export interface FormattedLegacyExperimentalIncrementalExecutionResults <
108+ TInitialData = ObjMap < unknown > ,
109+ TDeferredData = ObjMap < unknown > ,
110+ TStreamItem = unknown ,
111+ TExtensions = ObjMap < unknown > ,
112+ > {
113+ initialResult : FormattedLegacyInitialIncrementalExecutionResult <
114+ TInitialData ,
115+ TExtensions
116+ > ;
117+ subsequentResults : AsyncGenerator <
118+ FormattedLegacySubsequentIncrementalExecutionResult <
119+ TDeferredData ,
120+ TStreamItem ,
121+ TExtensions
122+ > ,
123+ void ,
124+ void
125+ > ;
126+ }
127+
128+ export interface FormattedLegacyInitialIncrementalExecutionResult <
129+ TInitialData = ObjMap < unknown > ,
130+ TExtensions = ObjMap < unknown > ,
131+ > extends FormattedExecutionResult < TInitialData , TExtensions > {
132+ data : TInitialData ;
133+ hasNext : true ;
134+ extensions ?: TExtensions ;
135+ }
136+
137+ export interface FormattedLegacySubsequentIncrementalExecutionResult <
138+ TDeferredData = ObjMap < unknown > ,
139+ TStreamItem = unknown ,
140+ TExtensions = ObjMap < unknown > ,
141+ > {
142+ incremental ?: ReadonlyArray <
143+ FormattedLegacyIncrementalResult < TDeferredData , TStreamItem , TExtensions >
144+ > ;
145+ hasNext : boolean ;
146+ extensions ?: TExtensions ;
147+ }
148+
149+ export type FormattedLegacyIncrementalResult <
150+ TDeferredData = ObjMap < unknown > ,
151+ TStreamItem = unknown ,
152+ TExtensions = ObjMap < unknown > ,
153+ > =
154+ | FormattedLegacyIncrementalDeferResult < TDeferredData , TExtensions >
155+ | FormattedLegacyIncrementalStreamResult < TStreamItem , TExtensions > ;
156+
157+ export interface FormattedLegacyIncrementalDeferResult <
158+ TDeferredData = ObjMap < unknown > ,
159+ TExtensions = ObjMap < unknown > ,
160+ > extends FormattedExecutionResult < TDeferredData , TExtensions > {
161+ path : ReadonlyArray < string | number > ;
162+ label ?: string ;
163+ }
164+
165+ export interface FormattedLegacyIncrementalStreamResult <
166+ TStreamItem = unknown ,
167+ TExtensions = ObjMap < unknown > ,
168+ > {
169+ errors ?: ReadonlyArray < GraphQLFormattedError > ;
170+ items : ReadonlyArray < TStreamItem > | null ;
171+ path : ReadonlyArray < string | number > ;
172+ label ?: string ;
173+ extensions ?: TExtensions ;
174+ }
85175/** @internal */
86- export class BranchingIncrementalExecutor extends IncrementalExecutor < ExperimentalIncrementalExecutionResults > {
176+ export class BranchingIncrementalExecutor extends IncrementalExecutor < LegacyExperimentalIncrementalExecutionResults > {
87177 override createSubExecutor (
88178 deferUsageSet ?: DeferUsageSet ,
89- ) : IncrementalExecutor < ExperimentalIncrementalExecutionResults > {
179+ ) : IncrementalExecutor < LegacyExperimentalIncrementalExecutionResults > {
90180 return new BranchingIncrementalExecutor (
91181 this . validatedExecutionArgs ,
92182 this . sharedResolverAbortSignal ,
@@ -96,7 +186,7 @@ export class BranchingIncrementalExecutor extends IncrementalExecutor<Experiment
96186
97187 override buildResponse (
98188 data : ObjMap < unknown > | null ,
99- ) : ExecutionResult | ExperimentalIncrementalExecutionResults {
189+ ) : ExecutionResult | LegacyExperimentalIncrementalExecutionResults {
100190 const work = this . getIncrementalWork ( ) ;
101191 const { tasks, streams } = work ;
102192 if ( tasks ?. length === 0 && streams ?. length === 0 ) {
0 commit comments