Skip to content

Conversation

@eddeee888
Copy link
Collaborator

@eddeee888 eddeee888 commented Nov 18, 2025

Description

This PR adds logic to generate enums in the generated file if used in operations Variables. This uses the enum conversion logic in #10520

This is a breaking change because previous setup with typescript plugin will break as both plugins now generate the same enum.

Related #10496

Note: there are some unfinished tests. I want to get the "used input types logic detection" into the feature branch first.

Type of change

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

How Has This Been Tested?

  • Unit test (partial, more test cases are coming in the following PR )

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: b5a7f27

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/typescript-operations Major
@graphql-codegen/client-preset 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 force-pushed the operations-collect-used-input branch from be9829d to 74a7a97 Compare November 25, 2025 13:08
Comment on lines +167 to +175
describe('TypeScript Operations Plugin - Enum', () => {
it.todo('does not generate unused enum in variables and result');
it.todo('handles native numeric enum correctly');
it.todo('handles const enum correctly');
it.todo('handles native const enum correctly');
it.todo('handles native enum correctly');
it.todo('handles EnumValues correctly');
// Bring over tests from https://github.com/dotansimha/graphql-code-generator/blob/accdab69106605241933e9d66d64dc7077656f30/packages/plugins/typescript/typescript/tests/typescript.spec.ts
});
Copy link
Collaborator Author

@eddeee888 eddeee888 Nov 25, 2025

Choose a reason for hiding this comment

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

These tests will be tested in a follow-up PR. I want to get the logic of detecting used input types into the feature branch first.

@eddeee888 eddeee888 changed the title [typescript-operations] Add generate enums if used in variables and result [typescript-operations] Add generate enums if used in Variables Nov 25, 2025
@eddeee888 eddeee888 changed the title [typescript-operations] Add generate enums if used in Variables [typescript-operations] Generate enums referenced in Variables Nov 25, 2025
@eddeee888 eddeee888 changed the title [typescript-operations] Generate enums referenced in Variables [typescript-operations] Generate enums referenced in operation Variables Nov 25, 2025
@eddeee888 eddeee888 marked this pull request as ready for review November 25, 2025 13:41
@eddeee888 eddeee888 merged commit 0461021 into master-next Nov 25, 2025
16 checks passed
@eddeee888 eddeee888 deleted the operations-collect-used-input branch November 25, 2025 13:47
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.

2 participants