Skip to content

Commit

Permalink
fix: duplicated description annotation on union fields (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored Apr 3, 2024
1 parent 78a7316 commit f1f0894
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/helpers/build-directive-annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 4 additions & 1 deletion test/unit/should_annotate_types_properly/expected.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions test/unit/should_annotate_types_properly/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f1f0894

Please sign in to comment.