@@ -100,7 +100,8 @@ export interface IncrementalDeferResult<
100
100
> {
101
101
errors ?: ReadonlyArray < GraphQLError > ;
102
102
data : TData ;
103
- path : ReadonlyArray < string | number > ;
103
+ id : string ;
104
+ subPath ?: ReadonlyArray < string | number > ;
104
105
extensions ?: TExtensions ;
105
106
}
106
107
@@ -110,7 +111,8 @@ export interface FormattedIncrementalDeferResult<
110
111
> {
111
112
errors ?: ReadonlyArray < GraphQLFormattedError > ;
112
113
data : TData ;
113
- path : ReadonlyArray < string | number > ;
114
+ id : string ;
115
+ subPath ?: ReadonlyArray < string | number > ;
114
116
extensions ?: TExtensions ;
115
117
}
116
118
@@ -120,7 +122,8 @@ export interface IncrementalStreamResult<
120
122
> {
121
123
errors ?: ReadonlyArray < GraphQLError > ;
122
124
items : TData ;
123
- path : ReadonlyArray < string | number > ;
125
+ id : string ;
126
+ subPath ?: ReadonlyArray < string | number > ;
124
127
extensions ?: TExtensions ;
125
128
}
126
129
@@ -130,7 +133,8 @@ export interface FormattedIncrementalStreamResult<
130
133
> {
131
134
errors ?: ReadonlyArray < GraphQLFormattedError > ;
132
135
items : TData ;
133
- path : ReadonlyArray < string | number > ;
136
+ id : string ;
137
+ subPath ?: ReadonlyArray < string | number > ;
134
138
extensions ?: TExtensions ;
135
139
}
136
140
@@ -146,13 +150,13 @@ export type FormattedIncrementalResult<
146
150
| FormattedIncrementalStreamResult < TData , TExtensions > ;
147
151
148
152
export interface PendingResult {
153
+ id : string ;
149
154
path : ReadonlyArray < string | number > ;
150
155
label ?: string ;
151
156
}
152
157
153
158
export interface CompletedResult {
154
- path : ReadonlyArray < string | number > ;
155
- label ?: string ;
159
+ id : string ;
156
160
errors ?: ReadonlyArray < GraphQLError > ;
157
161
}
158
162
@@ -178,6 +182,7 @@ export interface FormattedCompletedResult {
178
182
* @internal
179
183
*/
180
184
export class IncrementalPublisher {
185
+ private _nextId = 0 ;
181
186
private _released : Set < SubsequentResultRecord > ;
182
187
private _pending : Set < SubsequentResultRecord > ;
183
188
@@ -372,7 +377,10 @@ export class IncrementalPublisher {
372
377
const pendingResults : Array < PendingResult > = [ ] ;
373
378
for ( const pendingSource of pendingSources ) {
374
379
pendingSource . pendingSent = true ;
380
+ const id = this . _getNextId ( ) ;
381
+ pendingSource . id = id ;
375
382
const pendingResult : PendingResult = {
383
+ id,
376
384
path : pendingSource . path ,
377
385
} ;
378
386
if ( pendingSource . label !== undefined ) {
@@ -383,6 +391,10 @@ export class IncrementalPublisher {
383
391
return pendingResults ;
384
392
}
385
393
394
+ private _getNextId ( ) : string {
395
+ return String ( this . _nextId ++ ) ;
396
+ }
397
+
386
398
private _subscribe ( ) : AsyncGenerator <
387
399
SubsequentIncrementalExecutionResult ,
388
400
void ,
@@ -596,11 +608,9 @@ export class IncrementalPublisher {
596
608
completedRecord : DeferredFragmentRecord | StreamRecord ,
597
609
) : CompletedResult {
598
610
const result : CompletedResult = {
599
- path : completedRecord . path ,
611
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
612
+ id : completedRecord . id ! ,
600
613
} ;
601
- if ( completedRecord . label !== undefined ) {
602
- result . label = completedRecord . label ;
603
- }
604
614
if ( completedRecord . errors . length > 0 ) {
605
615
result . errors = completedRecord . errors ;
606
616
}
@@ -736,6 +746,7 @@ export class DeferredGroupedFieldSetRecord {
736
746
export class DeferredFragmentRecord {
737
747
path : ReadonlyArray < string | number > ;
738
748
label : string | undefined ;
749
+ id : string | undefined ;
739
750
children : Set < SubsequentResultRecord > ;
740
751
deferredGroupedFieldSetRecords : Set < DeferredGroupedFieldSetRecord > ;
741
752
errors : Array < GraphQLError > ;
@@ -758,6 +769,7 @@ export class DeferredFragmentRecord {
758
769
export class StreamRecord {
759
770
label : string | undefined ;
760
771
path : ReadonlyArray < string | number > ;
772
+ id : string | undefined ;
761
773
errors : Array < GraphQLError > ;
762
774
earlyReturn ?: ( ( ) => Promise < unknown > ) | undefined ;
763
775
pendingSent ?: boolean ;
0 commit comments