diff --git a/src/annotations/build-description-annotation.ts b/src/annotations/build-description-annotation.ts index e7b93a0..de2aee3 100644 --- a/src/annotations/build-description-annotation.ts +++ b/src/annotations/build-description-annotation.ts @@ -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( diff --git a/test/unit/should_annotate_types_properly/expected.kt b/test/unit/should_annotate_types_properly/expected.kt index 2f578ac..410fa38 100644 --- a/test/unit/should_annotate_types_properly/expected.kt +++ b/test/unit/should_annotate_types_properly/expected.kt @@ -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 +) diff --git a/test/unit/should_annotate_types_properly/schema.graphql b/test/unit/should_annotate_types_properly/schema.graphql index ffdde85..31eaf7c 100644 --- a/test/unit/should_annotate_types_properly/schema.graphql +++ b/test/unit/should_annotate_types_properly/schema.graphql @@ -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! +}