graphql-kotlin icon indicating copy to clipboard operation
graphql-kotlin copied to clipboard

Union Annotations Do Not Play Well with @GraphQLDescription and @Deprecated

Open danadajian opened this issue 11 months ago • 0 comments

Library Version Latest (7.0.2)

Describe the bug Using Kotlin annotation classes to define unions does not work with @Deprecated and sometimes does not work with @GraphQLDescription.

To Reproduce If you define an annotation class for a union like so:

@GraphQLUnion(
    name = "MyUnion",
    possibleTypes = [SomeUnionType::class],
    description = "Some union"
)
annotation class MyUnion

then the following will fail the graphqlGenerateSDL task with Cannot convert kotlin.Any? since it is not a valid GraphQL type or outside the supported packages:

data class MyType(
    @GraphQLDescription("Some description")
    @MyUnion
    val myField: Any? = null
)
data class MyType(
    @MyUnion
    @Deprecated("This is deprecated")
    val myField: Any? = null
)
data class MyType(
    @Deprecated("This is deprecated")
    @MyUnion
    val myField: Any? = null
)

Expected behavior All of the above data classes should be translated to SDL without error, since Kotlin annotations should not care about order.

danadajian avatar Mar 19 '24 16:03 danadajian