Skip to content

[typescript][typescript-resolvers] Fix enumValues not considering namingConvention in certain scenarios (2)#10657

Merged
eddeee888 merged 3 commits intomaster-nextfrom
master-next-fix-tests
Mar 31, 2026
Merged

[typescript][typescript-resolvers] Fix enumValues not considering namingConvention in certain scenarios (2)#10657
eddeee888 merged 3 commits intomaster-nextfrom
master-next-fix-tests

Conversation

@eddeee888
Copy link
Copy Markdown
Collaborator

@eddeee888 eddeee888 commented Mar 31, 2026

Description

This is the continuation of #10656. After merging said PR, I realised that the enumValues behaviour needs to be applied to typescript and typescript-resolvers as well.

Related #10496

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

🦋 Changeset detected

Latest commit: e6d2a4c

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

This PR includes changesets to release 3 packages
Name Type
@graphql-codegen/visitor-plugin-common Patch
@graphql-codegen/typescript Patch
@graphql-codegen/typescript-resolvers 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

@github-actions
Copy link
Copy Markdown
Contributor

🚀 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/cli 7.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/core 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/add 7.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/fragment-matcher 7.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/schema-ast 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/time 7.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 7.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 7.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 6.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/testing 5.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎
@graphql-codegen/plugin-helpers 7.0.0-alpha-20260331125845-e6d2a4ce6d2c1f46380441d80f8a3b827fbac6d8 npm ↗︎ unpkg ↗︎

Comment on lines -944 to -947
? this.convertName(this.config.enumValues[typeName].typeIdentifier, {
useTypesPrefix: false,
useTypesSuffix: false,
})
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.

typeIdentifierConverted is the converted enum type name, so we can safely use it across callsites

namingConvention: { enumValues: 'change-case-all#constantCase' },
enumValues: {
UserRole: './files#default as IUserRole',
UserRole: './files#default as UserRole', // NOTE: `as UserRole` doesn't do anything here, this is here to demonstrate that it's the same as './files#default'
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.

This as UserRole doesn't work at all for default imports, even on master 🤔
The fixed behaviour for default import: the name of the enum (UserRole) will have namingConvention applied (becomes IUserRole) so the subsequent references will work.

Comment on lines +688 to +689
expect(mergedOutputs).toContain(`C: GQL_C;`);
expect(mergedOutputs).toContain(`import { MyC as GQL_C } from '../enums.js';`);
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.

All imports and references must have naming convention applied, so subsequent refer to the enum type correctly.

@eddeee888 eddeee888 marked this pull request as ready for review March 31, 2026 13:08
@eddeee888 eddeee888 merged commit 3103b7a into master-next Mar 31, 2026
17 checks passed
@eddeee888 eddeee888 deleted the master-next-fix-tests branch March 31, 2026 13:08
eddeee888 added a commit that referenced this pull request Apr 13, 2026
…ingConvention in certain scenarios (2) (#10657)

* Ensure enumValues is consistent in typescript and typescript-resolvers

* Add a note to default alias import not doing anything

* Add changeset
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