smallrye-graphql
smallrye-graphql copied to clipboard
Error message differing for validation with blocking and non-blocking
When using the hibernate validator and having an api like this
@Mutation
public Uni<String> nonBlocking(@Valid Model model) {
return Uni.createFrom().item(model.getTest());
}
@Mutation
@Blocking
public Uni<String> blocking(@Valid Model model) {
return Uni.createFrom().item(model.getTest());
}
The resulting errors differs between blocking and non-blocking.
Result for non-blocking (my preferred one):
{
"errors": [
{
"message": "validation failed: nonBlocking.model.test size must be between 50 and 2147483647",
"locations": [
{
"line": 5,
"column": 22
},
{
"line": 5,
"column": 34
}
],
"path": [
"nonBlocking",
"model"
],
"extensions": {
"violation.propertyPath": [
"nonBlocking",
"model",
"test"
],
"violation.invalidValue": "test",
"violation.constraint": {
"groups": [],
"min": 50,
"message": "{javax.validation.constraints.Size.message}",
"payload": [],
"max": 2147483647
},
"violation.message": "size must be between 50 and 2147483647",
"classification": "ValidationError"
}
}
],
"data": {
"nonBlocking": null
}
}
Result for blocking:
{
"errors": [
{
"message": null,
"locations": [
{
"line": 1,
"column": 19
}
],
"path": [
"blocking"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": {
"blocking": null
}
}
I tried playing around with the show error message properties, but that did not help.
mp.graphql.showErrorMessage=io.smallrye.graphql.cdi.validation.BeanValidationException
quarkus.smallrye-graphql.show-runtime-exception-message=io.smallrye.graphql.cdi.validation.BeanValidationException
For blocking, the exception gets lost in io.quarkus.smallrye.graphql.runtime.spi.datafetcher.AbstractAsyncDataFetcher#invokeAndTransform code-with-quarkus-graphql-validation-blocking.zip
You can see the difference for example with those two mutations
mutation blocking{blocking(model:{
test:"test"
})}
mutation nonBlocking{nonBlocking(model:{
test:"test"
})}
Might be related to https://github.com/smallrye/smallrye-graphql/issues/1506, the symptom is the same
@jmartisk in the linked zulip chat you wrote with quarkus > 2.11, @GraphQLApi
is default @Singleton
. My reproducer is 2.12.3, and I just tried it with an additional @Singleton
at the api, which did not help.