Skip to content
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

[Codegen] Allow default value for non nullable variables #2760

Closed

Conversation

martinbonnin
Copy link
Contributor

@martinbonnin martinbonnin commented Nov 17, 2020

See #2686. This allow to omit the variable value if it has a defaultValue (even if the variable is non-nullable)

query launches($id: String! = "83") {
  launch(id: $id) {site}
}

will generate

// by default, id will be omitted 
data class LaunchesQuery(val id: Input<String> = Input.absent()) { ... }

I'm opening this mainly for reference. That's a potentially relatively seriously invasive/breaking change that has bitten us in the past (#2744, #2742). Given that it can be worked around relatively easily by passing the defaultValue in Kotlin code, and unless there are other important use cases I'm missing, this PR will only be merged for the next major version

(and input fields more generally)

```
query launches($id: String! = "83") {
  launch(id: $id) {site}
}
```

will now generate:

```
// by default, id will be omitted
data class LaunchesQuery(val id: Input<String> = Input.absent()) { ... }
```
@martinbonnin
Copy link
Contributor Author

Closing for now. Will reopen for 3.0

@martinbonnin martinbonnin deleted the allow-defaultValue-for-non-nullable-variables branch December 21, 2020 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant