Catch ValidationException in graphQLHttp

This commit is contained in:
Tobe O 2018-08-03 20:16:08 -04:00
parent a5a4dfe0b5
commit c69a53457f

View file

@ -48,6 +48,14 @@ RequestHandler graphQLHttp(GraphQL graphQl) {
} else { } else {
throw new AngelHttpException.badRequest(); throw new AngelHttpException.badRequest();
} }
} on ValidationException catch (e) {
var errors = <GraphQLExceptionError>[
new GraphQLExceptionError(e.message)
];
errors
.addAll(e.errors.map((ee) => new GraphQLExceptionError(ee)).toList());
return new GraphQLException(errors).toJson();
} on AngelHttpException catch (e) { } on AngelHttpException catch (e) {
var errors = <GraphQLExceptionError>[ var errors = <GraphQLExceptionError>[
new GraphQLExceptionError(e.message) new GraphQLExceptionError(e.message)