Skip to content

Commit 85adec5

Browse files
kazekyon1ru4l
authored andcommitted
Rename documentTransformPlugins to documentTransforms
1 parent 6d0d3bd commit 85adec5

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

packages/graphql-codegen-cli/src/codegen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
316316
emitLegacyCommonJSImports: shouldEmitLegacyCommonJSImports(config),
317317
};
318318

319-
const documentTransformPlugins = await Promise.all(
320-
normalizeConfig(outputConfig.documentTransformPlugins).map(async pluginConfig => {
319+
const documentTransforms = await Promise.all(
320+
normalizeConfig(outputConfig.documentTransforms).map(async pluginConfig => {
321321
const name = Object.keys(pluginConfig)[0];
322322
const plugin = await getPluginByName(name, pluginLoader);
323323
return { [name]: { plugin, config: Object.values(pluginConfig)[0] } };
@@ -338,7 +338,7 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
338338
pluginMap,
339339
pluginContext,
340340
profiler: context.profiler,
341-
documentTransformPlugins,
341+
documentTransforms,
342342
}),
343343
`Build Generates Section: ${filename}`
344344
)
@@ -353,7 +353,7 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
353353
pluginMap,
354354
pluginContext,
355355
profiler: context.profiler,
356-
documentTransformPlugins,
356+
documentTransforms,
357357
},
358358
];
359359

packages/graphql-codegen-cli/tests/codegen.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ describe('Codegen Executor', () => {
10951095
generates: {
10961096
'out1.ts': {
10971097
plugins: ['typescript', 'typescript-operations'],
1098-
documentTransformPlugins: ['./tests/custom-plugins/document-transform.js'],
1098+
documentTransforms: ['./tests/custom-plugins/document-transform.js'],
10991099
},
11001100
},
11011101
});
@@ -1111,7 +1111,7 @@ describe('Codegen Executor', () => {
11111111
generates: {
11121112
'out1.ts': {
11131113
plugins: ['typescript', 'typescript-operations'],
1114-
documentTransformPlugins: [
1114+
documentTransforms: [
11151115
{
11161116
'./tests/custom-plugins/document-transform-config.js': {
11171117
queryName: 'test',
@@ -1132,7 +1132,7 @@ describe('Codegen Executor', () => {
11321132
documents: `query root { f }`,
11331133
generates: {
11341134
'out1.ts': {
1135-
documentTransformPlugins: ['./tests/custom-plugins/document-transform-context.js'],
1135+
documentTransforms: ['./tests/custom-plugins/document-transform-context.js'],
11361136
plugins: ['./tests/custom-plugins/document-transform-context.js'],
11371137
},
11381138
},
@@ -1149,7 +1149,7 @@ describe('Codegen Executor', () => {
11491149
generates: {
11501150
'out1.ts': {
11511151
plugins: ['typescript'],
1152-
documentTransformPlugins: ['./tests/custom-plugins/document-transform-validation.js'],
1152+
documentTransforms: ['./tests/custom-plugins/document-transform-validation.js'],
11531153
},
11541154
},
11551155
});

packages/graphql-codegen-core/src/transform-document.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import { createNoopProfiler, Types } from '@graphql-codegen/plugin-helpers';
22
import { buildASTSchema, GraphQLSchema } from 'graphql';
33

44
export async function transformDocuments(options: Types.GenerateOptions): Promise<Types.DocumentFile[]> {
5-
const documentTransformPlugins = options.documentTransformPlugins || [];
5+
const documentTransforms = options.documentTransforms || [];
66
let documents = options.documents;
7-
if (documentTransformPlugins.length === 0) {
7+
if (documentTransforms.length === 0) {
88
return documents;
99
}
1010

1111
const profiler = options.profiler ?? createNoopProfiler();
1212
const outputSchema: GraphQLSchema = options.schemaAst || buildASTSchema(options.schema, options.config as any);
1313

14-
for (const documentTransformPlugin of documentTransformPlugins) {
15-
const name = Object.keys(documentTransformPlugin)[0];
16-
const transformPlugin = documentTransformPlugin[name].plugin;
17-
const pluginConfig = documentTransformPlugin[name].config;
14+
for (const documentTransform of documentTransforms) {
15+
const name = Object.keys(documentTransform)[0];
16+
const transformPlugin = documentTransform[name].plugin;
17+
const pluginConfig = documentTransform[name].config;
1818

1919
const config =
2020
typeof pluginConfig !== 'object'

packages/presets/client/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
240240
unmaskFunctionName: fragmentMaskingConfig.unmaskFunctionName,
241241
},
242242
documents: [],
243-
documentTransformPlugins: options.documentTransformPlugins,
243+
documentTransforms: options.documentTransforms,
244244
};
245245
}
246246

@@ -267,7 +267,7 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
267267
schema: options.schema,
268268
config: {},
269269
documents: [],
270-
documentTransformPlugins: options.documentTransformPlugins,
270+
documentTransforms: options.documentTransforms,
271271
};
272272
}
273273

@@ -282,7 +282,7 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
282282
...forwardedConfig,
283283
},
284284
documents: sources,
285-
documentTransformPlugins: options.documentTransformPlugins,
285+
documentTransforms: options.documentTransforms,
286286
},
287287
{
288288
filename: `${options.baseOutputDir}gql${gqlArtifactFileExtension}`,
@@ -294,7 +294,7 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
294294
gqlTagName: options.presetConfig.gqlTagName || 'graphql',
295295
},
296296
documents: sources,
297-
documentTransformPlugins: options.documentTransformPlugins,
297+
documentTransforms: options.documentTransforms,
298298
},
299299
...(isPersistedOperations
300300
? [

packages/presets/gql-tag-operations/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export const preset: Types.OutputPreset<GqlTagConfig> = {
207207
unmaskFunctionName: fragmentMaskingConfig.unmaskFunctionName,
208208
},
209209
documents: [],
210-
documentTransformPlugins: options.documentTransformPlugins,
210+
documentTransforms: options.documentTransforms,
211211
};
212212
}
213213

@@ -231,7 +231,7 @@ export const preset: Types.OutputPreset<GqlTagConfig> = {
231231
schema: options.schema,
232232
config: {},
233233
documents: [],
234-
documentTransformPlugins: options.documentTransformPlugins,
234+
documentTransforms: options.documentTransforms,
235235
};
236236
}
237237

@@ -243,7 +243,7 @@ export const preset: Types.OutputPreset<GqlTagConfig> = {
243243
schema: options.schema,
244244
config,
245245
documents: sources,
246-
documentTransformPlugins: options.documentTransformPlugins,
246+
documentTransforms: options.documentTransforms,
247247
},
248248
{
249249
filename: `${options.baseOutputDir}/gql${gqlArtifactFileExtension}`,
@@ -256,7 +256,7 @@ export const preset: Types.OutputPreset<GqlTagConfig> = {
256256
gqlTagName: options.presetConfig.gqlTagName || 'gql',
257257
},
258258
documents: sources,
259-
documentTransformPlugins: options.documentTransformPlugins,
259+
documentTransforms: options.documentTransforms,
260260
},
261261
...(fragmentMaskingFileGenerateConfig ? [fragmentMaskingFileGenerateConfig] : []),
262262
...(indexFileGenerateConfig ? [indexFileGenerateConfig] : []),

packages/presets/graphql-modules/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const preset: Types.OutputPreset<ModulesConfig> = {
6969
enumsAsTypes: true,
7070
},
7171
schemaAst: options.schemaAst!,
72-
documentTransformPlugins: options.documentTransformPlugins,
72+
documentTransforms: options.documentTransforms,
7373
};
7474

7575
const baseTypesFilename = baseTypesPath.replace(/\.(js|ts|d.ts)$/, '');
@@ -121,7 +121,7 @@ export const preset: Types.OutputPreset<ModulesConfig> = {
121121
},
122122
config: options.config,
123123
schemaAst: options.schemaAst,
124-
documentTransformPlugins: options.documentTransformPlugins,
124+
documentTransforms: options.documentTransforms,
125125
};
126126
});
127127

packages/utils/plugins-helpers/src/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export namespace Types {
1919
pluginContext?: { [key: string]: any };
2020
profiler?: Profiler;
2121
cache?<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T>;
22-
documentTransformPlugins?: ConfiguredDocumentTransformPlugin[];
22+
documentTransforms?: ConfiguredDocumentTransform[];
2323
}
2424

2525
export type FileOutput = {
@@ -233,7 +233,7 @@ export namespace Types {
233233
| 'import-types';
234234
export type PresetNames = `${PresetNamesBase}-preset` | PresetNamesBase;
235235

236-
export interface ConfiguredDocumentTransformPlugin {
236+
export interface ConfiguredDocumentTransform {
237237
[name: string]: { config: PluginConfig; plugin: CodegenPlugin };
238238
}
239239
/**
@@ -324,7 +324,7 @@ export namespace Types {
324324
* @description Specifies plugins that have the transformDocuments function.
325325
* Document transform plugin changes documents before executing plugins.
326326
*/
327-
documentTransformPlugins?: OutputConfig[];
327+
documentTransforms?: OutputConfig[];
328328
}
329329

330330
/* Output Builder Preset */
@@ -349,7 +349,7 @@ export namespace Types {
349349
};
350350
profiler?: Profiler;
351351
cache?<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T>;
352-
documentTransformPlugins: ConfiguredDocumentTransformPlugin[];
352+
documentTransforms: ConfiguredDocumentTransform[];
353353
};
354354

355355
export type OutputPreset<TPresetConfig = any> = {

0 commit comments

Comments
 (0)