Skip to content

Commit 1cd3dd0

Browse files
committed
add missing test
code coverage bug uncovered?
1 parent 7ce0d67 commit 1cd3dd0

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/execution/__tests__/defer-test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,56 @@ describe('Execute: defer directive', () => {
587587
]);
588588
});
589589

590+
it('Separately emits defer fragments with different labels with varying subfields that return promises', async () => {
591+
const document = parse(`
592+
query HeroNameQuery {
593+
... @defer(label: "DeferID") {
594+
hero {
595+
id
596+
}
597+
}
598+
... @defer(label: "DeferName") {
599+
hero {
600+
name
601+
}
602+
}
603+
}
604+
`);
605+
const result = await complete(document, {
606+
hero: {
607+
id: () => Promise.resolve('1'),
608+
name: () => Promise.resolve('Luke'),
609+
},
610+
});
611+
expectJSON(result).toDeepEqual([
612+
{
613+
data: {},
614+
hasNext: true,
615+
},
616+
{
617+
incremental: [
618+
{
619+
data: { hero: {} },
620+
path: [],
621+
},
622+
{
623+
data: { id: '1' },
624+
path: ['hero'],
625+
},
626+
{
627+
data: { name: 'Luke' },
628+
path: ['hero'],
629+
},
630+
],
631+
completed: [
632+
{ path: [], label: 'DeferID' },
633+
{ path: [], label: 'DeferName' },
634+
],
635+
hasNext: false,
636+
},
637+
]);
638+
});
639+
590640
it('Separately emits defer fragments with varying subfields of same priorities but different level of defers', async () => {
591641
const document = parse(`
592642
query HeroNameQuery {

0 commit comments

Comments
 (0)