Skip to content

Commit c6ebbf4

Browse files
authored
fix(incremental): fix paths for subsequent async stream items (graphql#4160)
1 parent 02ee34f commit c6ebbf4

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/execution/__tests__/stream-test.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,7 @@ describe('Execute: stream directive', () => {
21162116

21172117
const document = parse(`
21182118
query {
2119-
friendList @stream(initialCount: 1, label:"stream-label") {
2119+
friendList @stream(label:"stream-label") {
21202120
...NameFragment @defer(label: "DeferName") @defer(label: "DeferName")
21212121
id
21222122
}
@@ -2146,12 +2146,9 @@ describe('Execute: stream directive', () => {
21462146
const result1 = executeResult.initialResult;
21472147
expectJSON(result1).toDeepEqual({
21482148
data: {
2149-
friendList: [{ id: '1' }],
2149+
friendList: [],
21502150
},
2151-
pending: [
2152-
{ id: '0', path: ['friendList', 0], label: 'DeferName' },
2153-
{ id: '1', path: ['friendList'], label: 'stream-label' },
2154-
],
2151+
pending: [{ id: '0', path: ['friendList'], label: 'stream-label' }],
21552152
hasNext: true,
21562153
});
21572154

@@ -2160,13 +2157,18 @@ describe('Execute: stream directive', () => {
21602157
const result2 = await result2Promise;
21612158
expectJSON(result2).toDeepEqual({
21622159
value: {
2160+
pending: [{ id: '1', path: ['friendList', 0], label: 'DeferName' }],
21632161
incremental: [
21642162
{
2165-
data: { name: 'Luke' },
2163+
items: [{ id: '1' }],
21662164
id: '0',
21672165
},
2166+
{
2167+
data: { name: 'Luke' },
2168+
id: '1',
2169+
},
21682170
],
2169-
completed: [{ id: '0' }],
2171+
completed: [{ id: '1' }],
21702172
hasNext: true,
21712173
},
21722174
done: false,
@@ -2181,7 +2183,7 @@ describe('Execute: stream directive', () => {
21812183
incremental: [
21822184
{
21832185
items: [{ id: '2' }],
2184-
id: '1',
2186+
id: '0',
21852187
},
21862188
],
21872189
hasNext: true,
@@ -2191,7 +2193,7 @@ describe('Execute: stream directive', () => {
21912193
const result4 = await iterator.next();
21922194
expectJSON(result4).toDeepEqual({
21932195
value: {
2194-
completed: [{ id: '1' }],
2196+
completed: [{ id: '0' }],
21952197
hasNext: true,
21962198
},
21972199
done: false,

src/execution/execute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,7 @@ async function getNextAsyncStreamItemResult(
23872387
getNextAsyncStreamItemResult(
23882388
streamItemQueue,
23892389
streamPath,
2390-
index,
2390+
index + 1,
23912391
asyncIterator,
23922392
exeContext,
23932393
fieldGroup,

0 commit comments

Comments
 (0)