Skip to content

Commit dbfb294

Browse files
committed
should include parsing and validation errors in result
1 parent 8b3de5e commit dbfb294

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

packages/core/test/perform.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,38 @@ describe('perform', () => {
6969
i++;
7070
}
7171
});
72+
73+
it('should include parsing errors in result', async () => {
74+
const getEnveloped = envelop({ ...graphqlFuncs, plugins: [useSchema(schema)] });
75+
76+
const { perform } = getEnveloped();
77+
78+
const result = await perform({ query: '{' });
79+
assertSingleExecutionValue(result);
80+
81+
expect(result).toMatchInlineSnapshot(`
82+
Object {
83+
"errors": Array [
84+
[GraphQLError: Syntax Error: Expected Name, found <EOF>.],
85+
],
86+
}
87+
`);
88+
});
89+
90+
it('should include validation errors in result', async () => {
91+
const getEnveloped = envelop({ ...graphqlFuncs, plugins: [useSchema(schema)] });
92+
93+
const { perform } = getEnveloped();
94+
95+
const result = await perform({ query: '{ idontexist }' });
96+
assertSingleExecutionValue(result);
97+
98+
expect(result).toMatchInlineSnapshot(`
99+
Object {
100+
"errors": Array [
101+
[GraphQLError: Cannot query field "idontexist" on type "Query".],
102+
],
103+
}
104+
`);
105+
});
72106
});

0 commit comments

Comments
 (0)