Skip to content

Commit 4a38de2

Browse files
committed
don't send completed if pending was not sent
as now we hae true inlining
1 parent 26672e4 commit 4a38de2

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
@@ -1191,11 +1191,7 @@ describe('Execute: defer directive', () => {
11911191
path: ['hero', 'nestedObject', 'deeperObject'],
11921192
},
11931193
],
1194-
completed: [
1195-
{ path: ['hero'] },
1196-
{ path: ['hero', 'nestedObject'] },
1197-
{ path: ['hero', 'nestedObject', 'deeperObject'] },
1198-
],
1194+
completed: [{ path: ['hero'] }],
11991195
hasNext: false,
12001196
},
12011197
]);
@@ -1261,7 +1257,6 @@ describe('Execute: defer directive', () => {
12611257
completed: [
12621258
{ path: ['hero'] },
12631259
{ path: ['hero', 'nestedObject', 'deeperObject'] },
1264-
{ path: ['hero', 'nestedObject', 'deeperObject'] },
12651260
],
12661261
hasNext: false,
12671262
},
@@ -2094,12 +2089,7 @@ describe('Execute: defer directive', () => {
20942089
path: ['hero'],
20952090
},
20962091
],
2097-
completed: [
2098-
{ path: ['hero'] },
2099-
{ path: ['hero', 'friends', 0] },
2100-
{ path: ['hero', 'friends', 1] },
2101-
{ path: ['hero', 'friends', 2] },
2102-
],
2092+
completed: [{ path: ['hero'] }],
21032093
hasNext: false,
21042094
},
21052095
]);

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)