Skip to content

Fix const enum type prefix/suffix misconfiguration#10781

Merged
eddeee888 merged 4 commits into
masterfrom
fix-enum-type-prefix
May 6, 2026
Merged

Fix const enum type prefix/suffix misconfiguration#10781
eddeee888 merged 4 commits into
masterfrom
fix-enum-type-prefix

Conversation

@eddeee888
Copy link
Copy Markdown
Collaborator

Description

This is a bug that happened during the refactoring enum prefix/suffix when typesPrefix and typesSuffix is used with enumType=const specifically. In this case, typesPrefix is accidentally used in the typesSuffix slot.

This PR fixes the issue and add tests for relevant cases.

Related #10776

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 6, 2026

🦋 Changeset detected

Latest commit: 3452f12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@graphql-codegen/visitor-plugin-common Patch
@graphql-codegen/typescript-operations Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eddeee888 eddeee888 changed the title Fix const enum type prefix/suffix misconfiguration Fix const enum type prefix/suffix misconfiguration May 6, 2026
validateTs(result, undefined, undefined, undefined, undefined, true);
});

it('handles `native-numeric` enum with types prefix and suffix', async () => {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this test to ensure the behaviour is captured, even if it's not related to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/visitor-plugin-common 7.0.1-alpha-20260506131057-3452f127737a96e67180eff01da10092b2c5bad0 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.0.1-alpha-20260506131057-3452f127737a96e67180eff01da10092b2c5bad0 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.0.1-alpha-20260506131057-3452f127737a96e67180eff01da10092b2c5bad0 npm ↗︎ unpkg ↗︎

Comment on lines +149 to +150
Admin_ZZ = 0,
Customer_ZZ = 1
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the typesPrefix is not applied to enumValues e.g. this is Admin_ZZ and not AA_Admin_ZZ

I remember this is the previous behaviour. So I'm adding test here to be explicit to capture the current behaviour

(especially when it feels wrong, and should be fixed )

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

💻 Website Preview

The latest changes are available as preview in: https://pr-10781.graphql-code-generator.pages.dev

@eddeee888 eddeee888 merged commit 5f035cb into master May 6, 2026
31 of 32 checks passed
@eddeee888 eddeee888 deleted the fix-enum-type-prefix branch May 6, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant