Skip to content

Commit f1f0894

Browse files
authored
fix: duplicated description annotation on union fields (#25)
1 parent 78a7316 commit f1f0894

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/helpers/build-directive-annotations.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export function buildDirectiveAnnotations(
3939
deprecatedReasonNode?.kind === "StringValue"
4040
? deprecatedReasonNode.value
4141
: "";
42+
if (incomingNode.description?.value && resolvedType?.unionAnnotation) {
43+
return "";
44+
}
4245
const descriptionAnnotator = resolvedType?.unionAnnotation
4346
? "@GraphQLDescription"
4447
: "@Deprecated";

test/unit/should_annotate_types_properly/expected.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ data class MyType(
2222
val deprecated5: Any? = null,
2323
@MyUnion
2424
@GraphQLDescription("It uses the GraphQLDescription annotation for union types")
25-
val deprecated6: Any? = null
25+
val deprecated6: Any? = null,
26+
@MyUnion
27+
@GraphQLDescription("When there is a description")
28+
val deprecated7: Any? = null
2629
)
2730

2831
@GraphQLUnion(

test/unit/should_annotate_types_properly/schema.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ type MyType {
2424
@deprecated(
2525
reason: "It uses the GraphQLDescription annotation for union types"
2626
)
27+
"When there is a description"
28+
deprecated7: MyUnion
29+
@deprecated(reason: "It omits the @Deprecated annotation for now")
2730
}
2831

2932
union MyUnion = MyType

0 commit comments

Comments
 (0)