[Kotlin Client Codegen] Hello. I have issue with g...
# graphql-kotlin
d
[Kotlin Client Codegen] Hello. I have issue with generating
Enum
that as got
name
property. I have got Graphql server that has got enum class properties defined in UPPERCASE and renamed with
@GraphQLName
(because of
name
property).
Copy code
enum class EnumClass {
    @GraphQLName("id")
    @JsonProperty("id")
    ID,
    @GraphQLName("name")
    @JsonProperty("name")
    NAME,
    @GraphQLName("createdAt")
    @JsonProperty("createdAt")
    CREATED_AT,
    @GraphQLName("createdById")
    @JsonProperty("createdById")
    CREATED_BY_ID,
}
Now I want to use this type in my graphql-kotlin-client, but generator creates this class:
Copy code
enum class EnumClass {
    createdAt,
    createdById,
    id,
    name,
    /**
     * This is a default enum value that will be used when attempting to deserialize unknown value.
     */
    @JsonEnumDefaultValue
    __UNKNOWN_VALUE
}
There is a problem that Kotlin Enum cannot has got a
name
property. Please, it is possible to somehow solve it? Thank you
d
Name is a built in function for all enums (defaults to toString) so your custom enum clashes with jdk built in
Currently it wont be possible in the codegen to generate your enum
s
Yep, there is not much we can do if the enum value is invalid. As an aside comment, enums can be lowercase. While I also prefer the all uppercase style you could have this as your enum in your server code
Copy code
enum class EnumClass {
    id
    class_name, // This will clash so must change
    createdAt,
    createdById
}
d
Hi! Thank you for your response. I created issue on github for this question -> https://github.com/ExpediaGroup/graphql-kotlin/issues/1075 so we can discuss about it there 🙂