diff --git a/src/helpers/build-directive-annotations.ts b/src/helpers/build-directive-annotations.ts index cda2d8b..1c219d0 100644 --- a/src/helpers/build-directive-annotations.ts +++ b/src/helpers/build-directive-annotations.ts @@ -39,6 +39,9 @@ export function buildDirectiveAnnotations( deprecatedReasonNode?.kind === "StringValue" ? deprecatedReasonNode.value : ""; + if (incomingNode.description?.value && resolvedType?.unionAnnotation) { + return ""; + } const descriptionAnnotator = resolvedType?.unionAnnotation ? "@GraphQLDescription" : "@Deprecated"; diff --git a/test/unit/should_annotate_types_properly/expected.kt b/test/unit/should_annotate_types_properly/expected.kt index fb51de1..91d0f18 100644 --- a/test/unit/should_annotate_types_properly/expected.kt +++ b/test/unit/should_annotate_types_properly/expected.kt @@ -22,7 +22,10 @@ data class MyType( val deprecated5: Any? = null, @MyUnion @GraphQLDescription("It uses the GraphQLDescription annotation for union types") - val deprecated6: Any? = null + val deprecated6: Any? = null, + @MyUnion + @GraphQLDescription("When there is a description") + val deprecated7: Any? = null ) @GraphQLUnion( diff --git a/test/unit/should_annotate_types_properly/schema.graphql b/test/unit/should_annotate_types_properly/schema.graphql index 5b2a22b..45a889a 100644 --- a/test/unit/should_annotate_types_properly/schema.graphql +++ b/test/unit/should_annotate_types_properly/schema.graphql @@ -24,6 +24,9 @@ type MyType { @deprecated( reason: "It uses the GraphQLDescription annotation for union types" ) + "When there is a description" + deprecated7: MyUnion + @deprecated(reason: "It omits the @Deprecated annotation for now") } union MyUnion = MyType