Skip to content

Commit f3315d4

Browse files
committed
[typescript-operations] Add importSchemaTypesFrom to import user-defined+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
1 parent ac51c42 commit f3315d4

34 files changed

Lines changed: 777 additions & 288 deletions

.changeset/clever-loops-crash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-codegen/visitor-plugin-common': minor
3+
'@graphql-codegen/typescript-operations': minor
4+
---
5+
6+
Add importSchemaTypesFrom support

dev-test/codegen.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,25 @@ const config: CodegenConfig = {
256256
},
257257
},
258258
},
259+
260+
// standalone-operations
261+
'./dev-test/standalone-operations/import-schema-types/_base.generated.ts': {
262+
schema: './dev-test/standalone-operations/schema.graphql',
263+
documents: ['./dev-test/standalone-operations/import-schema-types/*.graphql'],
264+
plugins: ['typescript-operations'],
265+
config: {
266+
generatesOperationTypes: false,
267+
},
268+
},
269+
'./dev-test/standalone-operations/import-schema-types/_types.generated.ts': {
270+
schema: './dev-test/standalone-operations/schema.graphql',
271+
documents: ['./dev-test/standalone-operations/import-schema-types/*.graphql'],
272+
plugins: ['typescript-operations'],
273+
config: {
274+
importSchemaTypesFrom: './dev-test/standalone-operations/import-schema-types/_base.generated.ts',
275+
namespacedImportName: 'Types',
276+
},
277+
},
259278
},
260279
};
261280

dev-test/githunt/typed-document-nodes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,6 @@ export enum VoteType {
169169
Up = 'UP',
170170
}
171171

172-
/** A list of options for the sort order of the feed */
173-
export type FeedType =
174-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
175-
| 'HOT'
176-
/** Newest entries first */
177-
| 'NEW'
178-
/** Highest score entries first */
179-
| 'TOP';
180-
181-
/** The type of vote to record, when submitting a vote */
182-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
183-
184172
export type OnCommentAddedSubscriptionVariables = Exact<{
185173
repoFullName: string;
186174
}>;

dev-test/githunt/types.avoidOptionals.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ export enum VoteType {
168168
Up = 'UP',
169169
}
170170

171-
/** A list of options for the sort order of the feed */
172-
export type FeedType =
173-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
174-
| 'HOT'
175-
/** Newest entries first */
176-
| 'NEW'
177-
/** Highest score entries first */
178-
| 'TOP';
179-
180-
/** The type of vote to record, when submitting a vote */
181-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
182-
183171
export type OnCommentAddedSubscriptionVariables = Exact<{
184172
repoFullName: string;
185173
}>;

dev-test/githunt/types.d.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,6 @@ export type Vote = {
163163
/** The type of vote to record, when submitting a vote */
164164
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
165165

166-
/** A list of options for the sort order of the feed */
167-
export type FeedType =
168-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
169-
| 'HOT'
170-
/** Newest entries first */
171-
| 'NEW'
172-
/** Highest score entries first */
173-
| 'TOP';
174-
175-
/** The type of vote to record, when submitting a vote */
176-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
177-
178166
export type OnCommentAddedSubscriptionVariables = Exact<{
179167
repoFullName: string;
180168
}>;

dev-test/githunt/types.enumsAsTypes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,6 @@ export type Vote = {
163163
/** The type of vote to record, when submitting a vote */
164164
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
165165

166-
/** A list of options for the sort order of the feed */
167-
export type FeedType =
168-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
169-
| 'HOT'
170-
/** Newest entries first */
171-
| 'NEW'
172-
/** Highest score entries first */
173-
| 'TOP';
174-
175-
/** The type of vote to record, when submitting a vote */
176-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
177-
178166
export type OnCommentAddedSubscriptionVariables = Exact<{
179167
repoFullName: string;
180168
}>;

dev-test/githunt/types.flatten.preResolveTypes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ export enum VoteType {
168168
Up = 'UP',
169169
}
170170

171-
/** A list of options for the sort order of the feed */
172-
export type FeedType =
173-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
174-
| 'HOT'
175-
/** Newest entries first */
176-
| 'NEW'
177-
/** Highest score entries first */
178-
| 'TOP';
179-
180-
/** The type of vote to record, when submitting a vote */
181-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
182-
183171
export type OnCommentAddedSubscriptionVariables = Exact<{
184172
repoFullName: string;
185173
}>;

dev-test/githunt/types.immutableTypes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ export enum VoteType {
168168
Up = 'UP',
169169
}
170170

171-
/** A list of options for the sort order of the feed */
172-
export type FeedType =
173-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
174-
| 'HOT'
175-
/** Newest entries first */
176-
| 'NEW'
177-
/** Highest score entries first */
178-
| 'TOP';
179-
180-
/** The type of vote to record, when submitting a vote */
181-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
182-
183171
export type OnCommentAddedSubscriptionVariables = Exact<{
184172
repoFullName: string;
185173
}>;

dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ export enum VoteType {
3131
Up = 'UP',
3232
}
3333

34-
/** A list of options for the sort order of the feed */
35-
export type FeedType =
36-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
37-
| 'HOT'
38-
/** Newest entries first */
39-
| 'NEW'
40-
/** Highest score entries first */
41-
| 'TOP';
42-
43-
/** The type of vote to record, when submitting a vote */
44-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
45-
4634
export type OnCommentAddedSubscriptionVariables = Exact<{
4735
repoFullName: string;
4836
}>;

dev-test/githunt/types.preResolveTypes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ export enum VoteType {
168168
Up = 'UP',
169169
}
170170

171-
/** A list of options for the sort order of the feed */
172-
export type FeedType =
173-
/** Sort by a combination of freshness and score, using Reddit's algorithm */
174-
| 'HOT'
175-
/** Newest entries first */
176-
| 'NEW'
177-
/** Highest score entries first */
178-
| 'TOP';
179-
180-
/** The type of vote to record, when submitting a vote */
181-
export type VoteType = 'CANCEL' | 'DOWN' | 'UP';
182-
183171
export type OnCommentAddedSubscriptionVariables = Exact<{
184172
repoFullName: string;
185173
}>;

0 commit comments

Comments
 (0)