Skip to content

Commit 947b040

Browse files
committed
Test invalid onError is handled
1 parent a4cec5c commit 947b040

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/execution/__tests__/executor-test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,36 @@ describe('Execute: Handles basic execution tasks', () => {
933933
});
934934
});
935935

936+
it('raises request error with invalid onError', () => {
937+
const schema = new GraphQLSchema({
938+
query: new GraphQLObjectType({
939+
name: 'query',
940+
fields: () => ({
941+
a: {
942+
type: GraphQLInt,
943+
resolve: () => ({}),
944+
},
945+
}),
946+
}),
947+
});
948+
949+
const document = parse('{ a }');
950+
const result = executeSync({
951+
schema,
952+
document,
953+
// @ts-expect-error
954+
onError: 'DANCE',
955+
});
956+
expectJSON(result).toDeepEqual({
957+
errors: [
958+
{
959+
message:
960+
'Unsupported `onError` value; supported values are `PROPAGATE`, `NO_PROPAGATE` and `ABORT`.',
961+
},
962+
],
963+
});
964+
});
965+
936966
it('uses the inline operation if no operation name is provided', () => {
937967
const schema = new GraphQLSchema({
938968
query: new GraphQLObjectType({

0 commit comments

Comments
 (0)