Open
Description
The GraphQL spec allows for arguments to have default values:
Kotlin allows specifying default values:
This information is not available on reflection though due to the way Kotlin compiles to the JVM:
- https://discuss.kotlinlang.org/t/kotlin-reflection-and-default-values/2254
- https://discuss.kotlinlang.org/t/retrieve-default-parameter-value-via-reflection/7314
We could solve this issue by adding a new annotation @GraphQLDefaultValue
. This would require developers to duplicate some information but I think it would be worth it until we have a better way of extracting the info
fun getWidget(id: Int, @GraphQLDefaultValue(WidgetType.UNICORN) type: WidgetType = WidgetType.UNICORN) {
return database.getWidgetByIdAndType(id, type)
}