Skip to content

Commit

Permalink
polish: add additional test for filtering (#3749)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yaacovCR authored Sep 27, 2022
1 parent 5ae2e06 commit bd5aae7
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/execution/__tests__/stream-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,39 @@ describe('Execute: stream directive', () => {
},
});
});
it('Filters payloads that are nulled by a later synchronous error', async () => {
const document = parse(`
query {
nestedObject {
nestedFriendList @stream(initialCount: 0) {
name
}
nonNullScalarField
}
}
`);
const result = await complete(document, {
nestedObject: {
async *nestedFriendList() {
yield await Promise.resolve(friends[0]); /* c8 ignore start */
} /* c8 ignore stop */,
nonNullScalarField: () => null,
},
});
expectJSON(result).toDeepEqual({
errors: [
{
message:
'Cannot return null for non-nullable field NestedObject.nonNullScalarField.',
locations: [{ line: 7, column: 11 }],
path: ['nestedObject', 'nonNullScalarField'],
},
],
data: {
nestedObject: null,
},
});
});
it('Does not filter payloads when null error is in a different path', async () => {
const document = parse(`
query {
Expand Down

0 comments on commit bd5aae7

Please sign in to comment.