Add test for graphql type validation errors

While exploring ways to reproduce #313, I thought that validation errors
coming from GraphQL's internal type checking would reproduce the issue.
It didn't. But instead of throwing out the test I wrote, I thought it
might be good to keep it around to prevent future possible regressions.

I'll keep exploring ways to reproduce the issue I'm experiencing in a
subsequent commit(s).
This commit is contained in:
Henric Trotzig 2017-05-16 14:57:49 +02:00
parent 7c0dd0eee0
commit d6fe8a15d1

View file

@ -307,6 +307,29 @@ describe(`GraphQL-HTTP (apolloServer) tests for ${version} express`, () => {
});
});
it('handles type validation', async () => {
const app = express();
app.use(urlString(), bodyParser.json());
app.use(urlString(), graphqlExpress({
schema: TestSchema
}));
const response = await request(app)
.post(urlString())
.send({
query: '{test(who: 123)}',
});
expect(response.status).to.equal(400);
expect(JSON.parse(response.text)).to.deep.equal({
errors: [ {
message: 'Argument \"who\" has invalid value 123.\nExpected type \"String\", found 123.',
locations: [ { line: 1, column: 12 } ],
} ]
});
});
it('allows for custom error formatting to sanitize', async () => {
const app = express();