Skip to content

Commit 8ee3876

Browse files
committed
add tests
1 parent fd1fb25 commit 8ee3876

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/execution/__tests__/stream-test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const query = new GraphQLObjectType({
7171
async *resolve() {
7272
yield friends[0].name;
7373
yield {};
74+
yield friends[2].name;
7475
},
7576
},
7677
asyncIterableListDelayed: {
@@ -464,6 +465,42 @@ describe('Execute: stream directive', () => {
464465
},
465466
]);
466467
});
468+
it('Handles errors thrown by completeValue before initialCount is reached', async () => {
469+
const document = parse(`
470+
query {
471+
asyncIterableInvalid @stream(initialCount: 2)
472+
}
473+
`);
474+
const result = await complete(document);
475+
expect(result).to.deep.equal([
476+
{
477+
data: {
478+
asyncIterableInvalid: ['Luke', null],
479+
},
480+
errors: [
481+
{
482+
message: 'String cannot represent value: {}',
483+
locations: [
484+
{
485+
line: 3,
486+
column: 9,
487+
},
488+
],
489+
path: ['asyncIterableInvalid', 1],
490+
},
491+
],
492+
hasNext: true,
493+
},
494+
{
495+
data: 'Leia',
496+
path: ['asyncIterableInvalid', 2],
497+
hasNext: true,
498+
},
499+
{
500+
hasNext: false,
501+
},
502+
]);
503+
});
467504
it('Handles errors thrown by completeValue after initialCount is reached', async () => {
468505
const document = parse(`
469506
query {
@@ -495,6 +532,11 @@ describe('Execute: stream directive', () => {
495532
],
496533
hasNext: true,
497534
},
535+
{
536+
data: 'Leia',
537+
path: ['asyncIterableInvalid', 2],
538+
hasNext: true,
539+
},
498540
{
499541
hasNext: false,
500542
},

0 commit comments

Comments
 (0)