mirror of
https://github.com/vale981/apollo-server
synced 2025-03-05 17:51:40 -05:00
add a test for query syntax errors
This commit is contained in:
parent
e1a5f261d4
commit
c0b626c5de
1 changed files with 14 additions and 0 deletions
|
@ -71,6 +71,20 @@ describe('runQuery', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('returns a syntax error if the query string contains one', () => {
|
||||
const query = `query { test`;
|
||||
const expected = 'Syntax Error GraphQL (1:13) Expected Name, found EOF\n\n1: query { test\n ^\n';
|
||||
return runQuery({
|
||||
schema: Schema,
|
||||
query: query,
|
||||
variables: { base: 1 },
|
||||
}).then((res) => {
|
||||
expect(res.data).to.be.undefined;
|
||||
expect(res.errors.length).to.equal(1);
|
||||
return expect(res.errors[0].message).to.deep.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns a validation error if the query string does not pass validation', () => {
|
||||
const query = `query TestVar($base: String){ testArgumentValue(base: $base) }`;
|
||||
const expected = 'Variable "$base" of type "String" used in position expecting type "Int!".';
|
||||
|
|
Loading…
Add table
Reference in a new issue