-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to omit non-nullable variables if they have a defaultValue #2686
Comments
@renclav Most of use cases should work with #2704. This has been merged and will be available in the In all cases, I'm keeping this issue open (with an updated title) for input object default values, which will require more work. |
@martinbonnin 2.4.2-SNAPSHOT works well for me 🥳 |
Awesome :). Glad to hear that and perfect timing as I'm preparing the |
@renclav after some tests, passing the default value as default argument in the model constructor might not be the best way to do it since it will send a GraphQL variable by default, which might be counter intuitive. Can you elaborate on why you need the default value in the Kotlin models? Passing |
I'm going to close this one as not overriding the GraphQL document default variables seems to be the way to go, even for input objects (see #2741). Please leave a message if you want me to reopen it. |
Reopening this issues as there is more to it. While the solution of passing query launches($id: String! = "83") {
launch(id: $id) {site}
} will generate // no way to omit `id`
data class LaunchesQuery(val id: String) { ... } This means there's currently no way to omit the variable and let the GraphQL query document carry the defaultValue. A potential fix is to make variables with default values optional (in the Kotlin acceptation) as the current optional values (in the GraphQL acceptation) // by default, id will be omitted
data class LaunchesQuery(val id: Input<String> = Input.absent()) { ... } |
This should now work as expected in |
Is your feature request related to a problem? Please describe.
I would like to define default values for my query variables inside the query definitions defined in .graphql file/s. Currently this is possible, but the default values are ignored in the generated models.
Describe the solution you'd like
The client library follows the spec defined here which would result in kotlin query models being generated which include default values.
Notes:
The text was updated successfully, but these errors were encountered: