Skip to content

Commit

Permalink
fix(stream): continue on iterator error values
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yaacovCR committed Apr 11, 2021
1 parent d25cf40 commit ac0de32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/execution/__tests__/lists-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ describe('Execute: Accepts async iterables as list value', () => {
});
});

it('Handles an AsyncGenerator function where an intermediate value triggers an error', async () => {
async function* listField() {
yield await 'two';
yield await {};
yield await 4;
}

expect(await complete({ listField })).to.deep.equal({
data: { listField: ['two', null, '4'] },
errors: [
{
message: 'String cannot represent value: {}',
locations: [{ line: 1, column: 3 }],
path: ['listField', 1],
},
],
});
});

it('Handles errors from `completeValue` in AsyncIterables', async () => {
async function* listField() {
yield await 'two';
Expand Down
2 changes: 0 additions & 2 deletions src/execution/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,6 @@ function completeAsyncIteratorValue(
pathToArray(fieldPath),
);
handleFieldError(error, itemType, exeContext);
resolve(completedResults);
return;
}

next(index + 1, completedResults);
Expand Down

0 comments on commit ac0de32

Please sign in to comment.