Skip to content

Commit 7e95f42

Browse files
committed
polish: add additional test
note that filtering is still required for synchronous error bubbling with stream. With defer, patches are not executed if the initial field set execution fails, but with stream, the initial items (perhaps of zero length) will execute and will create the stream record.
1 parent 269d6aa commit 7e95f42

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/execution/__tests__/stream-test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,39 @@ describe('Execute: stream directive', () => {
979979
},
980980
});
981981
});
982+
it('Filters payloads that are nulled by a later synchronous error', async () => {
983+
const document = parse(`
984+
query {
985+
nestedObject {
986+
nestedFriendList @stream(initialCount: 0) {
987+
name
988+
}
989+
nonNullScalarField
990+
}
991+
}
992+
`);
993+
const result = await complete(document, {
994+
nestedObject: {
995+
async *nestedFriendList() {
996+
yield await Promise.resolve(friends[0]);
997+
},
998+
nonNullScalarField: () => null,
999+
},
1000+
});
1001+
expectJSON(result).toDeepEqual({
1002+
errors: [
1003+
{
1004+
message:
1005+
'Cannot return null for non-nullable field NestedObject.nonNullScalarField.',
1006+
locations: [{ line: 7, column: 11 }],
1007+
path: ['nestedObject', 'nonNullScalarField'],
1008+
},
1009+
],
1010+
data: {
1011+
nestedObject: null,
1012+
},
1013+
});
1014+
});
9821015
it('Does not filter payloads when null error is in a different path', async () => {
9831016
const document = parse(`
9841017
query {

0 commit comments

Comments
 (0)