mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 10:11:40 -05:00
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:
parent
7c0dd0eee0
commit
d6fe8a15d1
1 changed files with 23 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue