Did something in 4.0.0-alpha.15 change (vs. 3.7.0)...
# graphql-kotlin
r
Did something in 4.0.0-alpha.15 change (vs. 3.7.0) in regards to resolving nullable query/mutation parameter?
Copy code
@GraphQLDescription("performs some operation")
    fun doSomething(
        @GraphQLDescription("super important value")
        value: Int?
    ): Boolean = true
this works
Copy code
query {
  doSomething(value:null) {
    ..
  }
}
this fails in 4.0.0-alpha.15 :
no argument provided for a required parameter: parameter #1 query of fun SomeQuery.doSomething(<http://kotlin.Int?|kotlin.Int?>)
and works with 3.7.0
Copy code
query {
  doSomething {
    ..
  }
}
it works again when using a default
Copy code
@GraphQLDescription("performs some operation")
    fun doSomething(
        @GraphQLDescription("super important value")
        value: Int? = null
    ): Boolean = true
d
Yeah I think it was a side effect of fixing context handling and now nullable fields require explicit default null value. @Shane Myrick do you remember the details around it?
s
Ah, yes. I see what happened here. This could be fixed by modifying the function data fetcher
I remember why I did this now. If we check to see if the argument is not present in the GraphQL request and then pass in
null
to the function in that case, we will not be able to use Kotlin default values
Since we can’t inspect if a
KParameter
has a default value, we can only support one use case or the other. • Support Kotlin default values but require them for nullable input • Do not support Kotlin default values and always pass
null
for input if argument is missing in request
d
With null default we also cannot determine whether null was passed explicitly or was not present -> have to use the wrapper
I think supporting default values (even though it requires explicit null) is probably more useful
s
Yea, so then in that case it is a breaking change to 4.0.0. We haven’t really well documented the full list of changes from 3.x.x yet
👍 1
r
you guys already have a place where you want to document that? Could provide the example there as a PR if you like