Skip to content

Commit cc064a0

Browse files
committed
don't send completed if pending was not sent
as now we hae true inlining
1 parent 84b67fd commit cc064a0

File tree

3 files changed

+19
-31
lines changed

3 files changed

+19
-31
lines changed

src/execution/IncrementalPublisher.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,15 @@ export class IncrementalPublisher {
584584
}
585585
if (isStreamItemsRecord(subsequentResultRecord)) {
586586
if (subsequentResultRecord.isFinalRecord) {
587-
newPendingSources.delete(subsequentResultRecord.streamRecord);
588-
completedResults.push(
589-
this._completedRecordToResult(subsequentResultRecord.streamRecord),
590-
);
587+
if (newPendingSources.has(subsequentResultRecord.streamRecord)) {
588+
newPendingSources.delete(subsequentResultRecord.streamRecord);
589+
} else {
590+
completedResults.push(
591+
this._completedRecordToResult(
592+
subsequentResultRecord.streamRecord,
593+
),
594+
);
595+
}
591596
}
592597
if (subsequentResultRecord.isCompletedAsyncIterator) {
593598
// async iterable resolver just finished but there may be pending payloads
@@ -650,10 +655,13 @@ export class IncrementalPublisher {
650655
);
651656
}
652657
} else {
653-
newPendingSources.delete(subsequentResultRecord);
654-
completedResults.push(
655-
this._completedRecordToResult(subsequentResultRecord),
656-
);
658+
if (newPendingSources.has(subsequentResultRecord)) {
659+
newPendingSources.delete(subsequentResultRecord);
660+
} else {
661+
completedResults.push(
662+
this._completedRecordToResult(subsequentResultRecord),
663+
);
664+
}
657665
if (subsequentResultRecord.errors.length > 0) {
658666
continue;
659667
}

src/execution/__tests__/defer-test.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -1188,11 +1188,7 @@ describe('Execute: defer directive', () => {
11881188
path: ['hero', 'nestedObject', 'deeperObject'],
11891189
},
11901190
],
1191-
completed: [
1192-
{ path: ['hero'] },
1193-
{ path: ['hero', 'nestedObject'] },
1194-
{ path: ['hero', 'nestedObject', 'deeperObject'] },
1195-
],
1191+
completed: [{ path: ['hero'] }],
11961192
hasNext: false,
11971193
},
11981194
]);
@@ -1256,7 +1252,6 @@ describe('Execute: defer directive', () => {
12561252
completed: [
12571253
{ path: ['hero'] },
12581254
{ path: ['hero', 'nestedObject', 'deeperObject'] },
1259-
{ path: ['hero', 'nestedObject', 'deeperObject'] },
12601255
],
12611256
hasNext: false,
12621257
},
@@ -2062,12 +2057,7 @@ describe('Execute: defer directive', () => {
20622057
path: ['hero'],
20632058
},
20642059
],
2065-
completed: [
2066-
{ path: ['hero'] },
2067-
{ path: ['hero', 'friends', 0] },
2068-
{ path: ['hero', 'friends', 1] },
2069-
{ path: ['hero', 'friends', 2] },
2070-
],
2060+
completed: [{ path: ['hero'] }],
20712061
hasNext: false,
20722062
},
20732063
]);

src/execution/__tests__/stream-test.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,6 @@ describe('Execute: stream directive', () => {
355355
completed: [
356356
{ path: ['friendList'] },
357357
{ path: ['friendList', 0, 'appearsIn'] },
358-
{ path: ['friendList', 1, 'appearsIn'] },
359-
{ path: ['friendList', 2, 'appearsIn'] },
360358
],
361359
hasNext: false,
362360
},
@@ -404,15 +402,7 @@ describe('Execute: stream directive', () => {
404402
path: ['friendList', 0],
405403
},
406404
],
407-
completed: [
408-
{ path: ['friendList', 0] },
409-
{ path: ['friendList'] },
410-
{ path: ['friendList', 1] },
411-
{ path: ['friendList', 2] },
412-
{ path: ['friendList', 0, 'appearsIn'] },
413-
{ path: ['friendList', 1, 'appearsIn'] },
414-
{ path: ['friendList', 2, 'appearsIn'] },
415-
],
405+
completed: [{ path: ['friendList', 0] }, { path: ['friendList'] }],
416406
hasNext: false,
417407
},
418408
]);

0 commit comments

Comments
 (0)