@@ -14,11 +14,13 @@ limitations under the License.
1414import { CodegenConfig } from "../plugin" ;
1515import { DefinitionNode , isDeprecatedDescription } from "./build-annotations" ;
1616import { getFederationDirectiveReplacement } from "./get-federation-directive-replacement" ;
17+ import { TypeMetadata } from "./build-type-metadata" ;
1718
1819export function buildDirectiveAnnotations (
1920 incomingNode : DefinitionNode ,
2021 config : CodegenConfig ,
2122 description ?: string ,
23+ resolvedType ?: TypeMetadata ,
2224) {
2325 const kind = incomingNode . kind ;
2426 const directives = incomingNode . directives ?? [ ] ;
@@ -30,12 +32,17 @@ export function buildDirectiveAnnotations(
3032 directiveName === "deprecated" &&
3133 ! isDeprecatedDescription ( description )
3234 ) {
33- const deprecatedReason = directive . arguments ?. find (
35+ const deprecatedReasonNode = directive . arguments ?. find (
3436 ( arg ) => arg . name . value === "reason" ,
3537 ) ?. value ;
36- return `@Deprecated("${
37- deprecatedReason ?. kind === "StringValue" ? deprecatedReason . value : ""
38- } ")\n`;
38+ const deprecatedReason =
39+ deprecatedReasonNode ?. kind === "StringValue"
40+ ? deprecatedReasonNode . value
41+ : "" ;
42+ const descriptionAnnotator = resolvedType ?. unionAnnotation
43+ ? "@GraphQLDescription"
44+ : "@Deprecated" ;
45+ return `${ descriptionAnnotator } ("${ deprecatedReason } ")\n` ;
3946 }
4047 const federationReplacement =
4148 getFederationDirectiveReplacement ( directive ) ;
0 commit comments