Skip to content

Commit

Permalink
don't send completed if pending was not sent
Browse files Browse the repository at this point in the history
as now we hae true inlining
  • Loading branch information
yaacovCR committed Jul 16, 2023
1 parent 84b67fd commit cc064a0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
24 changes: 16 additions & 8 deletions src/execution/IncrementalPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,15 @@ export class IncrementalPublisher {
}
if (isStreamItemsRecord(subsequentResultRecord)) {
if (subsequentResultRecord.isFinalRecord) {
newPendingSources.delete(subsequentResultRecord.streamRecord);
completedResults.push(
this._completedRecordToResult(subsequentResultRecord.streamRecord),
);
if (newPendingSources.has(subsequentResultRecord.streamRecord)) {
newPendingSources.delete(subsequentResultRecord.streamRecord);
} else {
completedResults.push(
this._completedRecordToResult(
subsequentResultRecord.streamRecord,
),
);
}
}
if (subsequentResultRecord.isCompletedAsyncIterator) {
// async iterable resolver just finished but there may be pending payloads
Expand Down Expand Up @@ -650,10 +655,13 @@ export class IncrementalPublisher {
);
}
} else {
newPendingSources.delete(subsequentResultRecord);
completedResults.push(
this._completedRecordToResult(subsequentResultRecord),
);
if (newPendingSources.has(subsequentResultRecord)) {
newPendingSources.delete(subsequentResultRecord);
} else {
completedResults.push(
this._completedRecordToResult(subsequentResultRecord),
);
}
if (subsequentResultRecord.errors.length > 0) {
continue;
}
Expand Down
14 changes: 2 additions & 12 deletions src/execution/__tests__/defer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1188,11 +1188,7 @@ describe('Execute: defer directive', () => {
path: ['hero', 'nestedObject', 'deeperObject'],
},
],
completed: [
{ path: ['hero'] },
{ path: ['hero', 'nestedObject'] },
{ path: ['hero', 'nestedObject', 'deeperObject'] },
],
completed: [{ path: ['hero'] }],
hasNext: false,
},
]);
Expand Down Expand Up @@ -1256,7 +1252,6 @@ describe('Execute: defer directive', () => {
completed: [
{ path: ['hero'] },
{ path: ['hero', 'nestedObject', 'deeperObject'] },
{ path: ['hero', 'nestedObject', 'deeperObject'] },
],
hasNext: false,
},
Expand Down Expand Up @@ -2062,12 +2057,7 @@ describe('Execute: defer directive', () => {
path: ['hero'],
},
],
completed: [
{ path: ['hero'] },
{ path: ['hero', 'friends', 0] },
{ path: ['hero', 'friends', 1] },
{ path: ['hero', 'friends', 2] },
],
completed: [{ path: ['hero'] }],
hasNext: false,
},
]);
Expand Down
12 changes: 1 addition & 11 deletions src/execution/__tests__/stream-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,6 @@ describe('Execute: stream directive', () => {
completed: [
{ path: ['friendList'] },
{ path: ['friendList', 0, 'appearsIn'] },
{ path: ['friendList', 1, 'appearsIn'] },
{ path: ['friendList', 2, 'appearsIn'] },
],
hasNext: false,
},
Expand Down Expand Up @@ -404,15 +402,7 @@ describe('Execute: stream directive', () => {
path: ['friendList', 0],
},
],
completed: [
{ path: ['friendList', 0] },
{ path: ['friendList'] },
{ path: ['friendList', 1] },
{ path: ['friendList', 2] },
{ path: ['friendList', 0, 'appearsIn'] },
{ path: ['friendList', 1, 'appearsIn'] },
{ path: ['friendList', 2, 'appearsIn'] },
],
completed: [{ path: ['friendList', 0] }, { path: ['friendList'] }],
hasNext: false,
},
]);
Expand Down

0 comments on commit cc064a0

Please sign in to comment.