Skip to content

asyncIterable: locate async iterator errors to the collection #3899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/execution/__tests__/lists-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ describe('Execute: Accepts async iterables as list value', () => {
}

expectJSON(await complete({ listField })).toDeepEqual({
data: { listField: ['two', '4', null] },
data: { listField: null },
errors: [
{
message: 'bad',
locations: [{ line: 1, column: 3 }],
path: ['listField', 2],
path: ['listField'],
},
],
});
Expand Down
8 changes: 4 additions & 4 deletions src/execution/__tests__/stream-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,11 @@ describe('Execute: stream directive', () => {
{
message: 'bad',
locations: [{ line: 3, column: 9 }],
path: ['friendList', 1],
path: ['friendList'],
},
],
data: {
friendList: [{ name: 'Luke', id: '1' }, null],
friendList: null,
},
});
});
Expand Down Expand Up @@ -764,13 +764,13 @@ describe('Execute: stream directive', () => {
{
incremental: [
{
items: [null],
items: null,
path: ['friendList', 1],
errors: [
{
message: 'bad',
locations: [{ line: 3, column: 9 }],
path: ['friendList', 1],
path: ['friendList'],
},
],
},
Expand Down
24 changes: 4 additions & 20 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,16 +1093,7 @@ async function completeAsyncIteratorValue(
break;
}
} catch (rawError) {
handleFieldError(
rawError,
exeContext,
itemType,
fieldGroup,
itemPath,
incrementalDataRecord,
);
completedResults.push(null);
break;
throw locatedError(rawError, fieldGroup, pathToArray(path));
}

if (
Expand Down Expand Up @@ -1954,6 +1945,7 @@ async function executeStreamAsyncIteratorItem(
info: GraphQLResolveInfo,
itemType: GraphQLOutputType,
incrementalDataRecord: StreamItemsRecord,
path: Path,
itemPath: Path,
): Promise<IteratorResult<unknown>> {
let item;
Expand All @@ -1965,16 +1957,7 @@ async function executeStreamAsyncIteratorItem(
}
item = value;
} catch (rawError) {
handleFieldError(
rawError,
exeContext,
itemType,
fieldGroup,
itemPath,
incrementalDataRecord,
);
// don't continue if async iterator throws
return { done: true, value: null };
throw locatedError(rawError, fieldGroup, pathToArray(path));
}
let completedItem;
try {
Expand Down Expand Up @@ -2051,6 +2034,7 @@ async function executeStreamAsyncIterator(
info,
itemType,
incrementalDataRecord,
path,
itemPath,
);
} catch (error) {
Expand Down