Kotlin optional parameter changed in 4.0.0? #1126
-
We had this code working in version 3.x
Where names is set to
It is fixed by setting |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello 👋 See #981 |
Beta Was this translation helpful? Give feedback.
Hello 👋
Yes it was intentional. In older versions we always defaulted to null for optional arguments which while convenient was also ignoring any non-null defaults set in the code, i.e. given
fun foo(bar: String? = "baz")
it would always default tobar = null
. While we cannot read those default values using reflections (so cannot expose them in the schema), we changed the default data fetcher logic to only set the argument value if it was specified in the request so it correctly honors the defaults now - in the example belowbar
will default tobaz
. As a side effect this requires all optional arguments to specify their defaults explicitly.See #981