Skip to content

Conversation

@eddeee888
Copy link
Collaborator

Description

This PR fix an issue where external custom scalars are not imported correctly into files:

  • if a single file setup is used, external scalars import lines will be generated if used in Input, Variables or Result.
  • if multiple file setup is used:
    • operation file will have import lines for said scalars used in Variables or Result
    • shared type file will have import lines for said scalars used in Input

Related #10496

Type of change

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

How Has This Been Tested?

  • Unit test

@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2026

🦋 Changeset detected

Latest commit: 3a44df6

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

This PR includes changesets to release 1 package
Name Type
@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

Comment on lines +423 to +435
public getEnumsImports(): string[] {
const usedEnumMap: ParsedEnumValuesMap = {};
for (const [enumName, enumDetails] of Object.entries(this.config.enumValues)) {
if (this._usedNamedInputTypes[enumName]) {
usedEnumMap[enumName] = enumDetails;
}
}

return getEnumsImports({
enumValues: usedEnumMap,
useTypeImports: this.config.useTypeImports,
});
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this up here as a drive-by to keep similar imports methods closer together.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 25, 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/cli 6.1.2-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 5.0.1-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 7.0.0-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 5.0.8-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 5.1.3-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.0.0-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 6.0.0-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 6.1.6-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.0.0-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.0.0-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 5.1.3-alpha-20260125135505-3a44df6ccbf1d89c6f8128d64583d534868311e1 npm ↗︎ unpkg ↗︎

Comment on lines +576 to +578
if (usedInputTypes[node.name]) {
return;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

GraphQLInputObjectType and GraphQLEnumType don't have special cases like GraphQLScalarType where it may need special handling depending on where it's used (tracked by useCases). Therefore, we can return early for the former two if we've seen them previously

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is renamed to ts-douments.standalone.scalars.spec.ts

@eddeee888 eddeee888 merged commit 079138e into master-next Jan 25, 2026
19 checks passed
@eddeee888 eddeee888 deleted the master-next-handle-custom-scalar-import branch January 25, 2026 14:01
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