@@ -14,11 +14,13 @@ limitations under the License.
14
14
import { CodegenConfig } from "../plugin" ;
15
15
import { DefinitionNode , isDeprecatedDescription } from "./build-annotations" ;
16
16
import { getFederationDirectiveReplacement } from "./get-federation-directive-replacement" ;
17
+ import { TypeMetadata } from "./build-type-metadata" ;
17
18
18
19
export function buildDirectiveAnnotations (
19
20
incomingNode : DefinitionNode ,
20
21
config : CodegenConfig ,
21
22
description ?: string ,
23
+ resolvedType ?: TypeMetadata ,
22
24
) {
23
25
const kind = incomingNode . kind ;
24
26
const directives = incomingNode . directives ?? [ ] ;
@@ -30,12 +32,17 @@ export function buildDirectiveAnnotations(
30
32
directiveName === "deprecated" &&
31
33
! isDeprecatedDescription ( description )
32
34
) {
33
- const deprecatedReason = directive . arguments ?. find (
35
+ const deprecatedReasonNode = directive . arguments ?. find (
34
36
( arg ) => arg . name . value === "reason" ,
35
37
) ?. 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` ;
39
46
}
40
47
const federationReplacement =
41
48
getFederationDirectiveReplacement ( directive ) ;
0 commit comments