Juniper: Improve input object validation error messages

Created on 8 Jul 2020  路  1Comment  路  Source: graphql-rust/juniper

When an input object is validated and a field is missing or fails parsing then a general error message is returned to the client:

Invalid value for argument "foo", expected type "Foo!

This behavior can also be observed in this test.

From a client's perspective it is essential to know which field is missing/is failing to parse such that it can give appropriate feedback for the user's input. Therefore, I think that the error messages for input object validation should behave analogous to how it is the case for output objects where FieldResult is used to propagate such errors back to the client.

Example:
I'm proposing the test to assert something like

"ExampleInputObject!" field "b" missing

instead of

"Invalid value for argument "arg", expected type "ExampleInputObject!"

easy enhancement good-first-issue help wanted

Most helpful comment

Great idea!

>All comments

Great idea!

Was this page helpful?
0 / 5 - 0 ratings