Skip to content

Commit fe104be

Browse files
authored
fix inner stream with async iterables (#4544)
introduced in #4543
1 parent c718bcc commit fe104be

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/execution/Executor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,10 @@ export class Executor {
10531053
deliveryGroupMap: ReadonlyMap<DeferUsage, DeliveryGroup> | undefined,
10541054
): Promise<ReadonlyArray<unknown>> {
10551055
// do not stream inner lists of multi-dimensional lists
1056-
const streamUsage = getStreamUsage(
1057-
this.validatedExecutionArgs,
1058-
fieldDetailsList,
1059-
);
1056+
const streamUsage =
1057+
typeof path.key === 'number'
1058+
? undefined
1059+
: this.getStreamUsage(fieldDetailsList);
10601060

10611061
let containsPromise = false;
10621062
const completedResults: Array<unknown> = [];

src/execution/__tests__/stream-test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,12 +695,18 @@ describe('Execute: stream directive', () => {
695695
]);
696696
});
697697
it('Can stream multi-dimensional lists from async iterable', async () => {
698+
async function* innerList(fruit: string) {
699+
for (let i = 0; i < 3; i++) {
700+
// eslint-disable-next-line no-await-in-loop
701+
yield await Promise.resolve(fruit);
702+
}
703+
}
698704
const document = parse('{ scalarListList @stream(initialCount: 1) }');
699705
const result = await complete(document, {
700706
async *scalarListList() {
701-
yield await Promise.resolve(['apple', 'apple', 'apple']);
702-
yield await Promise.resolve(['banana', 'banana', 'banana']);
703-
yield await Promise.resolve(['coconut', 'coconut', 'coconut']);
707+
yield await Promise.resolve(innerList('apple'));
708+
yield await Promise.resolve(innerList('banana'));
709+
yield await Promise.resolve(innerList('coconut'));
704710
},
705711
});
706712
expectJSON(result).toDeepEqual([

0 commit comments

Comments
 (0)