Skip to content

Commit d9c4bd3

Browse files
committed
show failure in execution
1 parent 002a2ad commit d9c4bd3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/execution/__tests__/executor-test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars';
2222
import { GraphQLSchema } from '../../type/schema';
2323

2424
import { execute, executeSync } from '../execute';
25+
import { print } from '../../language';
2526

2627
describe('Execute: Handles basic execution tasks', () => {
2728
it('throws if no document is provided', () => {
@@ -72,6 +73,49 @@ describe('Execute: Handles basic execution tasks', () => {
7273
);
7374
});
7475

76+
it('works with deeply nested fragments', async () => {
77+
const DataType: GraphQLObjectType = new GraphQLObjectType({
78+
name: 'Query',
79+
fields: () => ({
80+
a: { type: GraphQLString, resolve: () => 'Apple' },
81+
}),
82+
});
83+
84+
85+
const n = 10000;
86+
const fragments = Array.from(Array(n).keys()).reduce(
87+
(acc, next) =>
88+
acc.concat(`\n
89+
fragment X${next + 1} on Query {
90+
...X${next}
91+
}
92+
`),
93+
'',
94+
);
95+
96+
const document = parse(`
97+
query {
98+
...X${n}
99+
__typename
100+
}
101+
${fragments}
102+
fragment X0 on Query {
103+
a
104+
}
105+
`);
106+
107+
const result = await execute({
108+
schema: new GraphQLSchema({ query: DataType }),
109+
document,
110+
});
111+
112+
expect(result).to.deep.equal({
113+
data: {
114+
a: 'Apple',
115+
},
116+
});
117+
});
118+
75119
it('executes arbitrary code', async () => {
76120
const data = {
77121
a: () => 'Apple',

0 commit comments

Comments
 (0)