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

Generate method return non optional fragment type in response-based codegen #6162

Open
sonatard opened this issue Sep 26, 2024 · 0 comments
Open

Comments

@sonatard
Copy link
Contributor

Use case

fragment StorefrontErrorMessage on DisplayableError {
    field
    message
}

mutation XUpdate($input: XInput!) {
    xrUpdate(x: $input,) {
        userErrors {
            ... StorefrontErrorMessage
        }
    }
}
fun create(storefrontErrorMessages: List<StorefrontErrorMessage>?): Throwable? { }

I need to use mapNotNull, but since it will never actually be null, I want to use map instead.

 StorefrontApiError.create(
            storefrontErrorMessages =
                xUpdate?.userErrors
-                    ?.mapNotNull { it.storefrontErrorMessage() }
+                    ?.map { it.storefrontErrorMessage() }
        )

Describe the solution you'd like

When it is not a union or interface, create a method that returns a non optional fragment type.

@sonatard sonatard changed the title Generate method return non optional fragment type Generate method return non optional fragment type in response-based codegen Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants