Skip to content

Commit 5600ebf

Browse files
committed
Support returning async iterables from resolver functions
1 parent d6f0ff9 commit 5600ebf

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/execution/__tests__/lists-test.ts

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

148+
it('Handles an AsyncGenerator function where an intermediate value triggers an error', async () => {
149+
async function* listField() {
150+
yield await Promise.resolve('two');
151+
yield await Promise.resolve({});
152+
yield await Promise.resolve(4);
153+
}
154+
155+
expect(await complete({ listField })).to.deep.equal({
156+
data: { listField: ['two', null, '4'] },
157+
errors: [
158+
{
159+
message: 'String cannot represent value: {}',
160+
locations: [{ line: 1, column: 3 }],
161+
path: ['listField', 1],
162+
},
163+
],
164+
});
165+
});
166+
148167
it('Handles errors from `completeValue` in AsyncIterables', async () => {
149168
async function* listField() {
150169
yield await Promise.resolve('two');

src/execution/execute.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,6 @@ function completeAsyncIteratorValue(
858858
);
859859
handleFieldError(error, itemType, exeContext);
860860
resolve(completedResults);
861-
return;
862861
}
863862

864863
next(index + 1, completedResults);

0 commit comments

Comments
 (0)