Skip to content

Commit 2535ed4

Browse files
committed
if an async iterator throws, this is an error located within the collection itself, not within the next pending item
as discussed in a prior incremental delivery WG meeting, this must be changed for both the non-streaming and streaming cases
1 parent e17a089 commit 2535ed4

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

src/execution/__tests__/lists-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ describe('Execute: Accepts async iterables as list value', () => {
141141
}
142142

143143
expectJSON(await complete({ listField })).toDeepEqual({
144-
data: { listField: ['two', '4', null] },
144+
data: { listField: null },
145145
errors: [
146146
{
147147
message: 'bad',
148148
locations: [{ line: 1, column: 3 }],
149-
path: ['listField', 2],
149+
path: ['listField'],
150150
},
151151
],
152152
});

src/execution/__tests__/stream-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,11 @@ describe('Execute: stream directive', () => {
731731
{
732732
message: 'bad',
733733
locations: [{ line: 3, column: 9 }],
734-
path: ['friendList', 1],
734+
path: ['friendList'],
735735
},
736736
],
737737
data: {
738-
friendList: [{ name: 'Luke', id: '1' }, null],
738+
friendList: null,
739739
},
740740
});
741741
});
@@ -764,13 +764,13 @@ describe('Execute: stream directive', () => {
764764
{
765765
incremental: [
766766
{
767-
items: [null],
767+
items: null,
768768
path: ['friendList', 1],
769769
errors: [
770770
{
771771
message: 'bad',
772772
locations: [{ line: 3, column: 9 }],
773-
path: ['friendList', 1],
773+
path: ['friendList'],
774774
},
775775
],
776776
},

src/execution/execute.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,16 +1093,7 @@ async function completeAsyncIteratorValue(
10931093
break;
10941094
}
10951095
} catch (rawError) {
1096-
handleFieldError(
1097-
rawError,
1098-
exeContext,
1099-
itemType,
1100-
fieldGroup,
1101-
itemPath,
1102-
incrementalDataRecord,
1103-
);
1104-
completedResults.push(null);
1105-
break;
1096+
throw locatedError(rawError, fieldGroup, pathToArray(path));
11061097
}
11071098

11081099
if (
@@ -1954,6 +1945,7 @@ async function executeStreamAsyncIteratorItem(
19541945
info: GraphQLResolveInfo,
19551946
itemType: GraphQLOutputType,
19561947
incrementalDataRecord: StreamItemsRecord,
1948+
path: Path,
19571949
itemPath: Path,
19581950
): Promise<IteratorResult<unknown>> {
19591951
let item;
@@ -1965,16 +1957,7 @@ async function executeStreamAsyncIteratorItem(
19651957
}
19661958
item = value;
19671959
} catch (rawError) {
1968-
handleFieldError(
1969-
rawError,
1970-
exeContext,
1971-
itemType,
1972-
fieldGroup,
1973-
itemPath,
1974-
incrementalDataRecord,
1975-
);
1976-
// don't continue if async iterator throws
1977-
return { done: true, value: null };
1960+
throw locatedError(rawError, fieldGroup, pathToArray(path));
19781961
}
19791962
let completedItem;
19801963
try {
@@ -2051,6 +2034,7 @@ async function executeStreamAsyncIterator(
20512034
info,
20522035
itemType,
20532036
incrementalDataRecord,
2037+
path,
20542038
itemPath,
20552039
);
20562040
} catch (error) {

0 commit comments

Comments
 (0)