Skip to content

Commit a56e6ab

Browse files
committed
Closes #1071
1 parent 8e15b1f commit a56e6ab

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/execution/__tests__/executor-test.js

+52
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,58 @@ describe('Execute: Handles basic execution tasks', () => {
536536
]);
537537
});
538538

539+
it('nulls error subtree for promise rejection #1071', async () => {
540+
const query = `
541+
query {
542+
foods {
543+
name
544+
}
545+
}
546+
`;
547+
548+
const schema = new GraphQLSchema({
549+
query: new GraphQLObjectType({
550+
name: 'Query',
551+
fields: {
552+
foods: {
553+
type: new GraphQLList(
554+
new GraphQLObjectType({
555+
name: 'Food',
556+
fields: {
557+
name: { type: GraphQLString },
558+
},
559+
}),
560+
),
561+
resolve() {
562+
return Promise.reject(new Error('Dangit'));
563+
},
564+
},
565+
},
566+
}),
567+
});
568+
569+
const ast = parse(query);
570+
const result = await execute(schema, ast);
571+
572+
expect(result).to.deep.equal({
573+
data: {
574+
foods: null,
575+
},
576+
errors: [
577+
{
578+
locations: [
579+
{
580+
column: 9,
581+
line: 3,
582+
},
583+
],
584+
message: 'Dangit',
585+
path: ['foods'],
586+
},
587+
],
588+
});
589+
});
590+
539591
it('Full response path is included for non-nullable fields', async () => {
540592
const A = new GraphQLObjectType({
541593
name: 'A',

0 commit comments

Comments
 (0)