Closed
Description
Hi, I'm on 1.0.0-M2 and trying to create a handler for a method with an optional field.
@QueryMapping
public Example example(@Argument Optional<String> relatedString) {
return exampleService.getExample(relatedString);
}
However, I keep getting the following response:
{
"errors": [
{
"message": "class java.util.Optional cannot be cast to class java.lang.String (java.util.Optional and java.lang.String are in module java.base of loader 'bootstrap')",
"locations": [
{
"line": 2,
"column": 5
}
],
"path": [
"example"
],
"extensions": {
"classification": "INTERNAL_ERROR"
}
}
],
"data": {
"example": null
}
}
When debugging, I found that relatedString
was being double wrapped with Optional
at runtime. In other words, the input to the method is actually Optional[Optional[stringThatMayBeHere]]
. I assume that this is not intentional.