Repository navigation
Fix type errors in generated types when queries use enums or input objects - #139
Open
saga-dasgupta wants to merge 2 commits into
Open
saga-dasgupta wants to merge 2 commits into
saga-dasgupta wants to merge 2 commits into
Conversation
typescript-operations 6 re-declares the enums and input objects that the typescript plugin already emits into the same file, so generated/api.ts fails to compile when an input query selects an enum field or uses enum or input object variables. Use GraphQL Codegen CLI 6.3.1, typescript 5.0.10 and typescript-operations 5.1.0. They don't depend on lodash, and generate the same output as 2.0.1.
The duplicate declarations are type errors: esbuild doesn't type-check, so functions still build. Inline the schema and query in the test, and drop the prepare variables test, which also passes on main.
saga-dasgupta
marked this pull request as ready for review
November 9, 2026 18:55
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
mainupdates GraphQL Codegen to v6 (#99), and the pending release (#137) would ship it. In v6,typescript-operationsre-declares the enums and input objects that thetypescriptplugin already writes to the same file. Function templates use both plugins, sogenerated/api.tshas type errors as soon as a query uses an enum or an input object:Functions still build, because esbuild doesn't type-check. But editors show the errors and
tscfails, so the generated types can't be type-checked, including when typing a prepare target's result with the run query's variables type. 3 of the 14 JavaScript function templates already hit this. Upstream won't change it (dotansimha/graphql-code-generator#10782).What
Use the last codegen releases before that change: CLI 6.3.1,
typescript5.0.10 andtypescript-operations5.1.0.Adds a test, run in a new CI workflow, that generates types the way Shopify CLI does and type-checks them. It fails on
main.Merge this before #137. Dependabot PRs that move codegen to v6 or v7 (#118, #120, #131, #133) bring this bug back, and the new test now fails on them.
Differences from 2.0.1
generated/api.tsare split across lines.skipTypename: true(not used by templates), an unselected union member is typedRecord<PropertyKey, never>instead of{}, which is slightly looser.Not changed here: the high-severity
@graphql-tools/utilsadvisories that come through the@graphql-tools/url-loaderandgraphql-configpins. 2.0.1 andmainhave them too.