Skip to content

Commit ac0de32

Browse files
committed
fix(stream): continue on iterator error values
if the iterator errors when attempting to get the next value, we can assume subsequent calls to next will also error, and abort, but if we successfully get the next value, but it ends up triggering an error, we can continue, optimistic that the next value will not do so.
1 parent d25cf40 commit ac0de32

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/execution/__tests__/lists-test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@ describe('Execute: Accepts async iterables as list value', () => {
139139
});
140140
});
141141

142+
it('Handles an AsyncGenerator function where an intermediate value triggers an error', async () => {
143+
async function* listField() {
144+
yield await 'two';
145+
yield await {};
146+
yield await 4;
147+
}
148+
149+
expect(await complete({ listField })).to.deep.equal({
150+
data: { listField: ['two', null, '4'] },
151+
errors: [
152+
{
153+
message: 'String cannot represent value: {}',
154+
locations: [{ line: 1, column: 3 }],
155+
path: ['listField', 1],
156+
},
157+
],
158+
});
159+
});
160+
142161
it('Handles errors from `completeValue` in AsyncIterables', async () => {
143162
async function* listField() {
144163
yield await 'two';

src/execution/execute.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,6 @@ function completeAsyncIteratorValue(
901901
pathToArray(fieldPath),
902902
);
903903
handleFieldError(error, itemType, exeContext);
904-
resolve(completedResults);
905-
return;
906904
}
907905

908906
next(index + 1, completedResults);

0 commit comments

Comments
 (0)