Skip to content

Commit a6806c4

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 0185dcc commit a6806c4

34 files changed

Lines changed: 770 additions & 291 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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,26 @@ const config: CodegenConfig = {
273273
plugins: ['typescript-operations'],
274274
},
275275
// #endregion
276+
277+
// standalone-operations
278+
'./dev-test/standalone-operations/import-schema-types/_base.generated.ts': {
279+
schema: './dev-test/standalone-operations/schema.graphql',
280+
documents: ['./dev-test/standalone-operations/import-schema-types/*.graphql'],
281+
plugins: ['typescript-operations'],
282+
config: {
283+
generatesOperationTypes: false,
284+
},
285+
},
286+
'./dev-test/standalone-operations/import-schema-types/_types.generated.ts': {
287+
schema: './dev-test/standalone-operations/schema.graphql',
288+
documents: ['./dev-test/standalone-operations/import-schema-types/*.graphql'],
289+
plugins: ['typescript-operations'],
290+
config: {
291+
importSchemaTypesFrom:
292+
'./dev-test/standalone-operations/import-schema-types/_base.generated.ts',
293+
namespacedImportName: 'Types',
294+
},
295+
},
276296
},
277297
};
278298

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,6 @@ export enum VoteType {
174174
Up = 'UP',
175175
}
176176

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

dev-test/githunt/types.avoidOptionals.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,6 @@ export enum VoteType {
172172
Up = 'UP',
173173
}
174174

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

dev-test/githunt/types.d.ts

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

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

dev-test/githunt/types.enumsAsTypes.ts

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

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

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,6 @@ export enum VoteType {
172172
Up = 'UP',
173173
}
174174

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

dev-test/githunt/types.immutableTypes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,6 @@ export enum VoteType {
172172
Up = 'UP',
173173
}
174174

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

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ export enum VoteType {
3535
Up = 'UP',
3636
}
3737

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

dev-test/githunt/types.preResolveTypes.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,6 @@ export enum VoteType {
172172
Up = 'UP',
173173
}
174174

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

0 commit comments

Comments
 (0)