-
Notifications
You must be signed in to change notification settings - Fork 657
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
Generate a Kotlin enum without the UNKNOWN__
case
#6243
Comments
For the record, after using both iOS & Kotlin Apollo libraries, I do like Apollo Kotlin's enum approach better as a starting point. Seeing Getting Started examples that have Ideally, Apollo Kotlin could just codegen a |
@joshuakcockrell an implementation is available at #6248. Let us know what you think |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Kotlin usage and allow us to serve you better. |
Wow, that's a crazy fast turnaround on this! I'm excited to test this out. Will let you know how it goes. |
Damn, I didn't mean to close this issue so fast, forgot that merging the PR would close the issue 🤦 |
@joshuakcockrell did you get a chance to test this? Just want to make sure it's working for you while while it's still hot. |
@martinbonnin I've been having difficulty getting the snapshot working. I got |
Hi @joshuakcockrell any update here? Would be nice to get confirmation it fits your use case before we cut a release. |
Use case
Currently,
when
statements need to match.UNKNOWN__
every time they're used in a codebase.This means I need to think through the
UNKNOWN
fallback several times.If the Apollo codegen provided an enum that didn't contain this case, I could instead write
Yes, nothing's currently stopping me from writing an
unwrap()
extension, but I still need to sprinkle__UNKNOWN
throughout my codebase to get thewhen
statements to compile.This is how Apollo iOS works, btw. GraphQLEnum.unknown is instead a wrapper enum around the core enum. On first glance, you would think Kotlin's approach is nicer because you don't need to match
.case(...)
, but every single when statement needs a default case to handle the.UNKNOWN__
, whereas iOS I can just create an unwrapper at the top level of my project to handle.unknown
once.Describe the solution you'd like
Apollo Kotlin already generates
knownEntries List
. If it just provided this exact thing inenum
format I could write my own project levelunwrap()
and my individualwhen
statements would never need to worry about.UNKNOWN__
.More context
Discord thread
The text was updated successfully, but these errors were encountered: