-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[typescript-operations] Add importSchemaTypesFrom to import user-defined+used input/enum types externally #10534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 55bd13e The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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}`; |
There was a problem hiding this comment.
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
| /** 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'; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added in https://github.com/dotansimha/graphql-code-generator/pull/10508/files#diff-93fb10b6a6c50ed7c1b33ca57cfbb1209c0d1d314d2edfdd3d2f04039dc8996dR243-R251 accidentally. This shouldn't be added unless it's used
…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
Description
We want
typescript-operationsto 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:
output enumandnested inputcan be done once Generate input types and output enums into target file #10527 is mergedType of change
How Has This Been Tested?