Skip to content

Conversation

@eddeee888
Copy link
Collaborator

@eddeee888 eddeee888 commented Dec 7, 2025

Description

We want typescript-operations to natively support importing types from another file. Previously, this is done by import-types preset, but it's a community plugin so keeping things in-sync is a bit tedious.

Part of feature branch: #10496

Related #10479

Notes:

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit test
  • Dev test (integration)

@changeset-bot
Copy link

changeset-bot bot commented Dec 7, 2025

🦋 Changeset detected

Latest commit: 55bd13e

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

This PR includes changesets to release 9 packages
Name Type
@graphql-codegen/visitor-plugin-common Minor
@graphql-codegen/typescript-operations Minor
@graphql-codegen/typescript-document-nodes Patch
@graphql-codegen/gql-tag-operations Patch
@graphql-codegen/typescript-resolvers Patch
@graphql-codegen/typed-document-node Patch
@graphql-codegen/typescript Patch
@graphql-codegen/graphql-modules-preset Patch
@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

const extraType = this.config.allowUndefinedQueryVariables && operationType === 'Query' ? ' | undefined' : '';

return `${prefix}Exact<${variablesBlock === '{}' ? `{ [key: string]: never; }` : variablesBlock}>${extraType}`;
return `Exact<${variablesBlock === '{}' ? `{ [key: string]: never; }` : variablesBlock}>${extraType}`;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exact is always local now, so we don't need to import it from the external file

@eddeee888 eddeee888 changed the title [typescript-operations] Add importSchemaTypesFrom [typescript-operations] Add importSchemaTypesFrom to import _user-defined_ and _used_ input/enum types externally Dec 7, 2025
@eddeee888 eddeee888 changed the title [typescript-operations] Add importSchemaTypesFrom to import _user-defined_ and _used_ input/enum types externally [typescript-operations] Add importSchemaTypesFrom to import user-defined+used input/enum types externally Dec 7, 2025
Comment on lines -243 to -251
/** The episodes in the Star Wars trilogy */
export type Episode =
/** Star Wars Episode V: The Empire Strikes Back, released in 1980. */
| 'EMPIRE'
/** Star Wars Episode VI: Return of the Jedi, released in 1983. */
| 'JEDI'
/** Star Wars Episode IV: A New Hope, released in 1977. */
| 'NEWHOPE';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@eddeee888 eddeee888 marked this pull request as ready for review December 8, 2025 13:51
@eddeee888 eddeee888 merged commit 20228d3 into master-next Dec 8, 2025
16 checks passed
@eddeee888 eddeee888 deleted the implement-importSchemaTypesFrom branch December 8, 2025 13:56
eddeee888 added a commit that referenced this pull request Jan 6, 2026
…ned+used input/enum types externally (#10534)

* Draft importSchemaTypesFrom

* Minor test fixes

* Fix test name

* Update dev-tests

* Baseline dev-test for importSchemaTypesFrom

* Implement relative import paths correctly

* Update tests to handle outputDir correctly

* Add test for absolute importSchemaTypesFrom

* Remove unncessary files

* Add test about unused things

* Remove comment

* Add comments

* 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.

2 participants