ExpediaGroup / graphql-kotlin

Libraries for running GraphQL in Kotlin
https://opensource.expediagroup.com/graphql-kotlin/
Apache License 2.0
1.74k stars 351 forks source link

graphq-kotlin-client code generator with duplicated fields #2050

Closed samuelAndalon closed 1 month ago

samuelAndalon commented 1 month ago

Library Version What version are you using? latest.

Describe the bug

[Error] Conflicting declarations: public final val text: String, public final val text: String

Generated data classes contain duplicated fields when using unions

To Reproduce Steps to reproduce the behavior. Please provide:


interface EGDSText {
    text: String!
}
type EGDSPlainText implements EGDSText {
    text: String!
}
union ProductRatingSupportingMessage = EGDSPlainText | ProductRatingLink

union ProductSupportingMessage = EGDSGraphicText | EGDSInlineLink | EGDSParagraph | EGDSPlainText | EGDSStandardBadge | LoyaltyDialogWithTrigger | EGDSLoyaltyBadge

Both ProductRatingSupportingMessage and ProductSupportingMessage share the EGDSPlainText type. However, when generating the Kotlin classes, I get something like this:

@Generated
public data class EGDSPlainText(
  public val text: String,
  public val text: String,
) : ProductRatingSupportingMessage, ProductSupportingMessage

Expected behavior data classes with unique fields.