Skip to content

Commit

Permalink
fix(incremental): fix paths for subsequent async stream items (#4160)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR authored Aug 13, 2024
1 parent 02ee34f commit c6ebbf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/execution/__tests__/stream-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ describe('Execute: stream directive', () => {

const document = parse(`
query {
friendList @stream(initialCount: 1, label:"stream-label") {
friendList @stream(label:"stream-label") {
...NameFragment @defer(label: "DeferName") @defer(label: "DeferName")
id
}
Expand Down Expand Up @@ -2146,12 +2146,9 @@ describe('Execute: stream directive', () => {
const result1 = executeResult.initialResult;
expectJSON(result1).toDeepEqual({
data: {
friendList: [{ id: '1' }],
friendList: [],
},
pending: [
{ id: '0', path: ['friendList', 0], label: 'DeferName' },
{ id: '1', path: ['friendList'], label: 'stream-label' },
],
pending: [{ id: '0', path: ['friendList'], label: 'stream-label' }],
hasNext: true,
});

Expand All @@ -2160,13 +2157,18 @@ describe('Execute: stream directive', () => {
const result2 = await result2Promise;
expectJSON(result2).toDeepEqual({
value: {
pending: [{ id: '1', path: ['friendList', 0], label: 'DeferName' }],
incremental: [
{
data: { name: 'Luke' },
items: [{ id: '1' }],
id: '0',
},
{
data: { name: 'Luke' },
id: '1',
},
],
completed: [{ id: '0' }],
completed: [{ id: '1' }],
hasNext: true,
},
done: false,
Expand All @@ -2181,7 +2183,7 @@ describe('Execute: stream directive', () => {
incremental: [
{
items: [{ id: '2' }],
id: '1',
id: '0',
},
],
hasNext: true,
Expand All @@ -2191,7 +2193,7 @@ describe('Execute: stream directive', () => {
const result4 = await iterator.next();
expectJSON(result4).toDeepEqual({
value: {
completed: [{ id: '1' }],
completed: [{ id: '0' }],
hasNext: true,
},
done: false,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,7 @@ async function getNextAsyncStreamItemResult(
getNextAsyncStreamItemResult(
streamItemQueue,
streamPath,
index,
index + 1,
asyncIterator,
exeContext,
fieldGroup,
Expand Down

0 comments on commit c6ebbf4

Please sign in to comment.