Skip to content

Commit 2309fb5

Browse files
committed
add failing test for a failed fragment with slower shared execution groups
1 parent 7912d6d commit 2309fb5

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

src/execution/__tests__/defer-test.ts

+78
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const a = new GraphQLObjectType({
9999
fields: {
100100
b: { type: b },
101101
someField: { type: GraphQLString },
102+
nonNullErrorField: { type: new GraphQLNonNull(GraphQLString) },
102103
},
103104
name: 'a',
104105
});
@@ -1688,6 +1689,83 @@ describe('Execute: defer directive', () => {
16881689
]);
16891690
});
16901691

1692+
it('Nulls cross defer boundaries, failed fragment with slower shared child execution groups', async () => {
1693+
const document = parse(`
1694+
query {
1695+
... @defer {
1696+
a {
1697+
someField
1698+
nonNullErrorField
1699+
b {
1700+
c {
1701+
d
1702+
}
1703+
}
1704+
}
1705+
}
1706+
a {
1707+
... @defer {
1708+
someField
1709+
b {
1710+
e {
1711+
f
1712+
}
1713+
}
1714+
}
1715+
}
1716+
}
1717+
`);
1718+
const result = await complete(document, {
1719+
a: {
1720+
b: { c: { d: 'd' }, e: { f: 'f' } },
1721+
someField: Promise.resolve('someField'),
1722+
},
1723+
});
1724+
expectJSON(result).toDeepEqual([
1725+
{
1726+
data: {
1727+
a: {},
1728+
},
1729+
pending: [
1730+
{ id: '0', path: [] },
1731+
{ id: '1', path: ['a'] },
1732+
],
1733+
hasNext: true,
1734+
},
1735+
{
1736+
completed: [
1737+
{
1738+
id: '0',
1739+
errors: [
1740+
{
1741+
message:
1742+
'Cannot return null for non-nullable field a.nonNullErrorField.',
1743+
locations: [{ line: 6, column: 13 }],
1744+
path: ['a', 'nonNullErrorField'],
1745+
},
1746+
],
1747+
},
1748+
],
1749+
hasNext: true,
1750+
},
1751+
{
1752+
incremental: [
1753+
{
1754+
data: { b: {}, someField: 'someField' },
1755+
id: '1',
1756+
},
1757+
{
1758+
data: { e: { f: 'f' } },
1759+
id: '1',
1760+
subPath: ['b'],
1761+
},
1762+
],
1763+
completed: [{ id: '1' }],
1764+
hasNext: false,
1765+
},
1766+
]);
1767+
});
1768+
16911769
it('Handles multiple erroring deferred grouped field sets', async () => {
16921770
const document = parse(`
16931771
query {

0 commit comments

Comments
 (0)