I have this QueryMapping method where I have some parameters marked as required in my GrapthQL schema, but not all. Using @Argument
allows me to grab all required parameters, but when I send a Query without an optional parameter it crashes. Using the RequestParam
annotation with a default value doesn't work since its type is an integer and the annotation requires a string. (I guess it's supposed to be called within a REST-API)
@QueryMapping
public List<Record> getRecord(Argument String email, @Argument int dateFrom, @RequestParam(required = false, defaultValue = 0) int dateTo) {
return repository.findSpecific(email, dateFrom);
}
Edit: Method overloading does not work.
What can I do?
I found a solution by using Kotlin: Adding a Question mark behind the Parameter Type allows me to set the value to null.