@graphql-codegen/cli 6.0.3-alpha-20251115121823-72e57eca5d8e2e6ae9a642532cf4c41692466f7c → 6.1.0-alpha-20251119131248-4aa0bce27decc294509fae591f5c2236858abdbb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/codegen.js +8 -3
- package/cjs/config.js +15 -13
- package/esm/codegen.js +10 -5
- package/esm/config.js +15 -12
- package/package.json +3 -3
- package/typings/config.d.cts +13 -1
- package/typings/config.d.ts +13 -1
package/cjs/codegen.js
CHANGED
|
@@ -245,12 +245,17 @@ async function executeCodegen(input) {
|
|
|
245
245
|
const name = Object.keys(plugin)[0];
|
|
246
246
|
return [name, pkg];
|
|
247
247
|
}));
|
|
248
|
+
const importExtension = (0, plugin_helpers_1.normalizeImportExtension)({
|
|
249
|
+
emitLegacyCommonJSImports: config.emitLegacyCommonJSImports,
|
|
250
|
+
importExtension: config.importExtension,
|
|
251
|
+
});
|
|
248
252
|
const mergedConfig = {
|
|
249
253
|
...rootConfig,
|
|
250
254
|
...(typeof outputFileTemplateConfig === 'string'
|
|
251
255
|
? { value: outputFileTemplateConfig }
|
|
252
256
|
: outputFileTemplateConfig),
|
|
253
|
-
|
|
257
|
+
importExtension,
|
|
258
|
+
emitLegacyCommonJSImports: config.emitLegacyCommonJSImports ?? true,
|
|
254
259
|
};
|
|
255
260
|
const documentTransforms = Array.isArray(outputConfig.documentTransforms)
|
|
256
261
|
? await Promise.all(outputConfig.documentTransforms.map(async (config, index) => {
|
|
@@ -288,8 +293,8 @@ async function executeCodegen(input) {
|
|
|
288
293
|
const process = async (outputArgs) => {
|
|
289
294
|
const output = await (0, core_1.codegen)({
|
|
290
295
|
...outputArgs,
|
|
291
|
-
|
|
292
|
-
emitLegacyCommonJSImports:
|
|
296
|
+
importExtension,
|
|
297
|
+
emitLegacyCommonJSImports: config.emitLegacyCommonJSImports ?? true,
|
|
293
298
|
cache,
|
|
294
299
|
});
|
|
295
300
|
result.push({
|
package/cjs/config.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.parseArgv = parseArgv;
|
|
|
9
9
|
exports.createContext = createContext;
|
|
10
10
|
exports.updateContextWithCliFlags = updateContextWithCliFlags;
|
|
11
11
|
exports.ensureContext = ensureContext;
|
|
12
|
-
exports.shouldEmitLegacyCommonJSImports = shouldEmitLegacyCommonJSImports;
|
|
13
12
|
const tslib_1 = require("tslib");
|
|
14
13
|
const crypto_1 = require("crypto");
|
|
15
14
|
const fs_1 = require("fs");
|
|
@@ -178,6 +177,18 @@ function buildOptions() {
|
|
|
178
177
|
type: 'boolean',
|
|
179
178
|
default: false,
|
|
180
179
|
},
|
|
180
|
+
'emit-legacy-common-js-imports': {
|
|
181
|
+
describe: 'Emit legacy CommonJS imports (deprecated, use import-extension instead)',
|
|
182
|
+
type: 'boolean',
|
|
183
|
+
},
|
|
184
|
+
'import-extension': {
|
|
185
|
+
describe: 'Extension to append to imports (e.g., .js, .mjs, or empty string for no extension)',
|
|
186
|
+
type: 'string',
|
|
187
|
+
},
|
|
188
|
+
'ignore-no-documents': {
|
|
189
|
+
describe: 'Suppress errors for no documents',
|
|
190
|
+
type: 'boolean',
|
|
191
|
+
},
|
|
181
192
|
};
|
|
182
193
|
}
|
|
183
194
|
function parseArgv(argv = process.argv) {
|
|
@@ -225,6 +236,9 @@ function updateContextWithCliFlags(context, cliFlags) {
|
|
|
225
236
|
// for some reason parsed value is `'false'` string so this ensure it always is a boolean.
|
|
226
237
|
config.emitLegacyCommonJSImports = cliFlags['emit-legacy-common-js-imports'] === true;
|
|
227
238
|
}
|
|
239
|
+
if (cliFlags['import-extension'] !== undefined) {
|
|
240
|
+
config.importExtension = cliFlags['import-extension'];
|
|
241
|
+
}
|
|
228
242
|
if (cliFlags.project) {
|
|
229
243
|
context.useProject(cliFlags.project);
|
|
230
244
|
}
|
|
@@ -352,15 +366,3 @@ function addHashToDocumentFiles(documentFilesPromise) {
|
|
|
352
366
|
return doc;
|
|
353
367
|
}));
|
|
354
368
|
}
|
|
355
|
-
function shouldEmitLegacyCommonJSImports(config) {
|
|
356
|
-
const globalValue = config.emitLegacyCommonJSImports === undefined ? true : !!config.emitLegacyCommonJSImports;
|
|
357
|
-
// const outputConfig = config.generates[outputPath];
|
|
358
|
-
// if (!outputConfig) {
|
|
359
|
-
// debugLog(`Couldn't find a config of ${outputPath}`);
|
|
360
|
-
// return globalValue;
|
|
361
|
-
// }
|
|
362
|
-
// if (isConfiguredOutput(outputConfig) && typeof outputConfig.emitLegacyCommonJSImports === 'boolean') {
|
|
363
|
-
// return outputConfig.emitLegacyCommonJSImports;
|
|
364
|
-
// }
|
|
365
|
-
return globalValue;
|
|
366
|
-
}
|
package/esm/codegen.js
CHANGED
|
@@ -3,11 +3,11 @@ import { createRequire } from 'module';
|
|
|
3
3
|
import { cpus } from 'os';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { codegen } from '@graphql-codegen/core';
|
|
6
|
-
import { getCachedDocumentNodeFromSchema, normalizeConfig, normalizeInstanceOrArray, normalizeOutputParam, } from '@graphql-codegen/plugin-helpers';
|
|
6
|
+
import { getCachedDocumentNodeFromSchema, normalizeConfig, normalizeImportExtension, normalizeInstanceOrArray, normalizeOutputParam, } from '@graphql-codegen/plugin-helpers';
|
|
7
7
|
import { NoTypeDefinitionsFound } from '@graphql-tools/load';
|
|
8
8
|
import { GraphQLError } from 'graphql';
|
|
9
9
|
import { Listr } from 'listr2';
|
|
10
|
-
import { ensureContext
|
|
10
|
+
import { ensureContext } from './config.js';
|
|
11
11
|
import { getPluginByName } from './plugins.js';
|
|
12
12
|
import { getPresetByName } from './presets.js';
|
|
13
13
|
import { debugLog, printLogs } from './utils/debugging.js';
|
|
@@ -241,12 +241,17 @@ export async function executeCodegen(input) {
|
|
|
241
241
|
const name = Object.keys(plugin)[0];
|
|
242
242
|
return [name, pkg];
|
|
243
243
|
}));
|
|
244
|
+
const importExtension = normalizeImportExtension({
|
|
245
|
+
emitLegacyCommonJSImports: config.emitLegacyCommonJSImports,
|
|
246
|
+
importExtension: config.importExtension,
|
|
247
|
+
});
|
|
244
248
|
const mergedConfig = {
|
|
245
249
|
...rootConfig,
|
|
246
250
|
...(typeof outputFileTemplateConfig === 'string'
|
|
247
251
|
? { value: outputFileTemplateConfig }
|
|
248
252
|
: outputFileTemplateConfig),
|
|
249
|
-
|
|
253
|
+
importExtension,
|
|
254
|
+
emitLegacyCommonJSImports: config.emitLegacyCommonJSImports ?? true,
|
|
250
255
|
};
|
|
251
256
|
const documentTransforms = Array.isArray(outputConfig.documentTransforms)
|
|
252
257
|
? await Promise.all(outputConfig.documentTransforms.map(async (config, index) => {
|
|
@@ -284,8 +289,8 @@ export async function executeCodegen(input) {
|
|
|
284
289
|
const process = async (outputArgs) => {
|
|
285
290
|
const output = await codegen({
|
|
286
291
|
...outputArgs,
|
|
287
|
-
|
|
288
|
-
emitLegacyCommonJSImports:
|
|
292
|
+
importExtension,
|
|
293
|
+
emitLegacyCommonJSImports: config.emitLegacyCommonJSImports ?? true,
|
|
289
294
|
cache,
|
|
290
295
|
});
|
|
291
296
|
result.push({
|
package/esm/config.js
CHANGED
|
@@ -165,6 +165,18 @@ export function buildOptions() {
|
|
|
165
165
|
type: 'boolean',
|
|
166
166
|
default: false,
|
|
167
167
|
},
|
|
168
|
+
'emit-legacy-common-js-imports': {
|
|
169
|
+
describe: 'Emit legacy CommonJS imports (deprecated, use import-extension instead)',
|
|
170
|
+
type: 'boolean',
|
|
171
|
+
},
|
|
172
|
+
'import-extension': {
|
|
173
|
+
describe: 'Extension to append to imports (e.g., .js, .mjs, or empty string for no extension)',
|
|
174
|
+
type: 'string',
|
|
175
|
+
},
|
|
176
|
+
'ignore-no-documents': {
|
|
177
|
+
describe: 'Suppress errors for no documents',
|
|
178
|
+
type: 'boolean',
|
|
179
|
+
},
|
|
168
180
|
};
|
|
169
181
|
}
|
|
170
182
|
export function parseArgv(argv = process.argv) {
|
|
@@ -212,6 +224,9 @@ export function updateContextWithCliFlags(context, cliFlags) {
|
|
|
212
224
|
// for some reason parsed value is `'false'` string so this ensure it always is a boolean.
|
|
213
225
|
config.emitLegacyCommonJSImports = cliFlags['emit-legacy-common-js-imports'] === true;
|
|
214
226
|
}
|
|
227
|
+
if (cliFlags['import-extension'] !== undefined) {
|
|
228
|
+
config.importExtension = cliFlags['import-extension'];
|
|
229
|
+
}
|
|
215
230
|
if (cliFlags.project) {
|
|
216
231
|
context.useProject(cliFlags.project);
|
|
217
232
|
}
|
|
@@ -338,15 +353,3 @@ function addHashToDocumentFiles(documentFilesPromise) {
|
|
|
338
353
|
return doc;
|
|
339
354
|
}));
|
|
340
355
|
}
|
|
341
|
-
export function shouldEmitLegacyCommonJSImports(config) {
|
|
342
|
-
const globalValue = config.emitLegacyCommonJSImports === undefined ? true : !!config.emitLegacyCommonJSImports;
|
|
343
|
-
// const outputConfig = config.generates[outputPath];
|
|
344
|
-
// if (!outputConfig) {
|
|
345
|
-
// debugLog(`Couldn't find a config of ${outputPath}`);
|
|
346
|
-
// return globalValue;
|
|
347
|
-
// }
|
|
348
|
-
// if (isConfiguredOutput(outputConfig) && typeof outputConfig.emitLegacyCommonJSImports === 'boolean') {
|
|
349
|
-
// return outputConfig.emitLegacyCommonJSImports;
|
|
350
|
-
// }
|
|
351
|
-
return globalValue;
|
|
352
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0-alpha-20251119131248-4aa0bce27decc294509fae591f5c2236858abdbb",
|
|
4
4
|
"peerDependenciesMeta": {
|
|
5
5
|
"@parcel/watcher": {
|
|
6
6
|
"optional": true
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"@babel/generator": "^7.18.13",
|
|
15
15
|
"@babel/template": "^7.18.10",
|
|
16
16
|
"@babel/types": "^7.18.13",
|
|
17
|
-
"@graphql-codegen/client-preset": "
|
|
17
|
+
"@graphql-codegen/client-preset": "5.2.0-alpha-20251119131248-4aa0bce27decc294509fae591f5c2236858abdbb",
|
|
18
18
|
"@graphql-codegen/core": "^5.0.0",
|
|
19
|
-
"@graphql-codegen/plugin-helpers": "
|
|
19
|
+
"@graphql-codegen/plugin-helpers": "6.1.0-alpha-20251119131248-4aa0bce27decc294509fae591f5c2236858abdbb",
|
|
20
20
|
"@graphql-tools/apollo-engine-loader": "^8.0.0",
|
|
21
21
|
"@graphql-tools/code-file-loader": "^8.0.0",
|
|
22
22
|
"@graphql-tools/git-loader": "^8.0.0",
|
package/typings/config.d.cts
CHANGED
|
@@ -16,6 +16,7 @@ export type YamlCliFlags = {
|
|
|
16
16
|
debug?: boolean;
|
|
17
17
|
ignoreNoDocuments?: boolean;
|
|
18
18
|
emitLegacyCommonJSImports?: boolean;
|
|
19
|
+
importExtension?: '' | `.${string}`;
|
|
19
20
|
};
|
|
20
21
|
export declare function generateSearchPlaces(moduleName: string): string[];
|
|
21
22
|
export type CodegenConfigLoader = (filepath: string, content: string) => Promise<Types.Config> | Types.Config;
|
|
@@ -103,6 +104,18 @@ export declare function buildOptions(): {
|
|
|
103
104
|
type: "boolean";
|
|
104
105
|
default: boolean;
|
|
105
106
|
};
|
|
107
|
+
'emit-legacy-common-js-imports': {
|
|
108
|
+
describe: string;
|
|
109
|
+
type: "boolean";
|
|
110
|
+
};
|
|
111
|
+
'import-extension': {
|
|
112
|
+
describe: string;
|
|
113
|
+
type: "string";
|
|
114
|
+
};
|
|
115
|
+
'ignore-no-documents': {
|
|
116
|
+
describe: string;
|
|
117
|
+
type: "boolean";
|
|
118
|
+
};
|
|
106
119
|
};
|
|
107
120
|
export declare function parseArgv(argv?: string[]): YamlCliFlags;
|
|
108
121
|
export declare function createContext(cliFlags?: YamlCliFlags): Promise<CodegenContext>;
|
|
@@ -137,4 +150,3 @@ export declare class CodegenContext {
|
|
|
137
150
|
loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
|
|
138
151
|
}
|
|
139
152
|
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|
|
140
|
-
export declare function shouldEmitLegacyCommonJSImports(config: Types.Config): boolean;
|
package/typings/config.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type YamlCliFlags = {
|
|
|
16
16
|
debug?: boolean;
|
|
17
17
|
ignoreNoDocuments?: boolean;
|
|
18
18
|
emitLegacyCommonJSImports?: boolean;
|
|
19
|
+
importExtension?: '' | `.${string}`;
|
|
19
20
|
};
|
|
20
21
|
export declare function generateSearchPlaces(moduleName: string): string[];
|
|
21
22
|
export type CodegenConfigLoader = (filepath: string, content: string) => Promise<Types.Config> | Types.Config;
|
|
@@ -103,6 +104,18 @@ export declare function buildOptions(): {
|
|
|
103
104
|
type: "boolean";
|
|
104
105
|
default: boolean;
|
|
105
106
|
};
|
|
107
|
+
'emit-legacy-common-js-imports': {
|
|
108
|
+
describe: string;
|
|
109
|
+
type: "boolean";
|
|
110
|
+
};
|
|
111
|
+
'import-extension': {
|
|
112
|
+
describe: string;
|
|
113
|
+
type: "string";
|
|
114
|
+
};
|
|
115
|
+
'ignore-no-documents': {
|
|
116
|
+
describe: string;
|
|
117
|
+
type: "boolean";
|
|
118
|
+
};
|
|
106
119
|
};
|
|
107
120
|
export declare function parseArgv(argv?: string[]): YamlCliFlags;
|
|
108
121
|
export declare function createContext(cliFlags?: YamlCliFlags): Promise<CodegenContext>;
|
|
@@ -137,4 +150,3 @@ export declare class CodegenContext {
|
|
|
137
150
|
loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
|
|
138
151
|
}
|
|
139
152
|
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|
|
140
|
-
export declare function shouldEmitLegacyCommonJSImports(config: Types.Config): boolean;
|