From d2911c54f0d592e5e938d206fe72701af693e900 Mon Sep 17 00:00:00 2001 From: nebbles Date: Sat, 1 Feb 2025 08:53:19 +0000 Subject: [PATCH] fix: Add deprecated directive to enumsAsConst Use the BaseTypesVisitor getNodeComment to build the comment string (which uses transformComment under the hood) rather than just using the transform. The getNodeComment method already has support for intepreting and transforming deprecated directives correctly, as is seen in the default output for enums. --- .changeset/funny-lamps-sort.md | 5 +++++ packages/plugins/typescript/typescript/src/visitor.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/funny-lamps-sort.md diff --git a/.changeset/funny-lamps-sort.md b/.changeset/funny-lamps-sort.md new file mode 100644 index 00000000000..0a7e7c00747 --- /dev/null +++ b/.changeset/funny-lamps-sort.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/visitor-plugin-common': minor +--- + +enumsAsConst output now includes deprecated directive diff --git a/packages/plugins/typescript/typescript/src/visitor.ts b/packages/plugins/typescript/typescript/src/visitor.ts index 55c4ebd33c9..ca363d089a7 100644 --- a/packages/plugins/typescript/typescript/src/visitor.ts +++ b/packages/plugins/typescript/typescript/src/visitor.ts @@ -443,7 +443,7 @@ export class TsVisitor< transformUnderscore: true, }) ); - const comment = transformComment(enumOption.description as any as string, 1); + const comment = this.getNodeComment(enumOption); const name = enumOption.name as unknown as string; const enumValue: string | number = getValueFromConfig(name) ?? name;