Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/annotations/build-description-annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export function buildDescriptionAnnotation(
const isDeprecatedDescription = trimmedDescription.startsWith(
deprecatedDescriptionPrefix,
);
if (isDeprecatedDescription && typeMetadata?.unionAnnotation) {
const isRequiredInputField =
definitionNode.kind === Kind.INPUT_VALUE_DEFINITION &&
definitionNode.type.kind === Kind.NON_NULL_TYPE;
if (
isDeprecatedDescription &&
(typeMetadata?.unionAnnotation || isRequiredInputField)
) {
return `@GraphQLDescription("${trimmedDescription}")\n`;
} else if (isDeprecatedDescription) {
const descriptionValue = description.replace(
Expand Down
8 changes: 8 additions & 0 deletions test/unit/should_annotate_types_properly/expected.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ data class TypeThatShouldBeProperlyAnnotated(
) : UnionThatShouldBeProperlyAnnotated

interface UnionThatShouldBeProperlyAnnotated

@GraphQLValidObjectLocations(locations = [GraphQLValidObjectLocations.Locations.INPUT_OBJECT])
data class InputTypeThatShouldBeProperlyAnnotated(
@Deprecated("this field is deprecated")
val optionalField: String? = null,
@GraphQLDescription("DEPRECATED: this field is deprecated")
val requiredField: String
)
7 changes: 7 additions & 0 deletions test/unit/should_annotate_types_properly/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ type TypeThatShouldBeProperlyAnnotated {
}

union UnionThatShouldBeProperlyAnnotated = TypeThatShouldBeProperlyAnnotated

input InputTypeThatShouldBeProperlyAnnotated {
"DEPRECATED: this field is deprecated"
optionalField: String
"DEPRECATED: this field is deprecated"
requiredField: String!
}