@graphql-codegen/cli 5.0.8-alpha-20250627132114-c24a6143ab3a6f442f962ee2b22460fc7215b05b → 6.0.0-alpha-20250627115156-9c57b83a4553fcece2f9fa6d83a61efd06c03b16
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 +4 -4
- package/cjs/generate-and-save.js +13 -1
- package/cjs/utils/watcher.js +2 -2
- package/esm/codegen.js +4 -4
- package/esm/generate-and-save.js +12 -1
- package/esm/utils/watcher.js +2 -2
- package/package.json +4 -4
- package/typings/codegen.d.cts +4 -1
- package/typings/codegen.d.ts +4 -1
package/cjs/codegen.js
CHANGED
|
@@ -332,12 +332,12 @@ async function executeCodegen(input) {
|
|
|
332
332
|
// if we have debug logs, make sure to print them before throwing the errors
|
|
333
333
|
(0, debugging_js_1.printLogs)();
|
|
334
334
|
}
|
|
335
|
+
let error = null;
|
|
335
336
|
if (executedContext.errors.length > 0) {
|
|
336
337
|
const errors = executedContext.errors.map(subErr => subErr.message || subErr.toString());
|
|
337
|
-
|
|
338
|
+
error = new AggregateError(executedContext.errors, String(errors.join('\n\n')));
|
|
338
339
|
// Best-effort to all stack traces for debugging
|
|
339
|
-
|
|
340
|
-
throw newErr;
|
|
340
|
+
error.stack = `${error.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
341
341
|
}
|
|
342
|
-
return result;
|
|
342
|
+
return { result, error };
|
|
343
343
|
}
|
package/cjs/generate-and-save.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = generate;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const crypto_1 = require("crypto");
|
|
5
6
|
const path_1 = require("path");
|
|
7
|
+
const log_symbols_1 = tslib_1.__importDefault(require("log-symbols"));
|
|
6
8
|
const codegen_js_1 = require("./codegen.js");
|
|
7
9
|
const config_js_1 = require("./config.js");
|
|
8
10
|
const hooks_js_1 = require("./hooks.js");
|
|
9
11
|
const debugging_js_1 = require("./utils/debugging.js");
|
|
10
12
|
const file_system_js_1 = require("./utils/file-system.js");
|
|
11
13
|
const watcher_js_1 = require("./utils/watcher.js");
|
|
14
|
+
const logger_js_1 = require("./utils/logger.js");
|
|
12
15
|
const hash = (content) => (0, crypto_1.createHash)('sha1').update(content).digest('base64');
|
|
13
16
|
async function generate(input, saveToFile = true) {
|
|
14
17
|
const context = (0, config_js_1.ensureContext)(input);
|
|
@@ -99,7 +102,16 @@ async function generate(input, saveToFile = true) {
|
|
|
99
102
|
if (config.watch) {
|
|
100
103
|
return (0, watcher_js_1.createWatcher)(context, writeOutput).runningWatcher;
|
|
101
104
|
}
|
|
102
|
-
const outputFiles = await context.profiler.run(() => (0, codegen_js_1.executeCodegen)(context), 'executeCodegen');
|
|
105
|
+
const { result: outputFiles, error } = await context.profiler.run(() => (0, codegen_js_1.executeCodegen)(context), 'executeCodegen');
|
|
106
|
+
if (error) {
|
|
107
|
+
if (config.writeOnPartialSuccess) {
|
|
108
|
+
(0, logger_js_1.getLogger)().warn(` ${log_symbols_1.default.warning} One or more errors occurred while generating files. Successful processes wrote output to files.`);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
(0, logger_js_1.getLogger)().error(` ${log_symbols_1.default.error} One or more errors occurred while generating files. No output was written to files.`);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
103
115
|
await context.profiler.run(() => writeOutput(outputFiles), 'writeOutput');
|
|
104
116
|
await context.profiler.run(() => (0, hooks_js_1.lifecycleHooks)(config.hooks).beforeDone(), 'Lifecycle: beforeDone');
|
|
105
117
|
if (context.profilerOutput) {
|
package/cjs/utils/watcher.js
CHANGED
|
@@ -48,7 +48,7 @@ const createWatcher = (initialContext, onNext) => {
|
|
|
48
48
|
const debouncedExec = (0, debounce_1.default)(() => {
|
|
49
49
|
if (!isShutdown) {
|
|
50
50
|
(0, codegen_js_1.executeCodegen)(initialContext)
|
|
51
|
-
.then(onNext, () => Promise.resolve())
|
|
51
|
+
.then(({ result }) => onNext(result), () => Promise.resolve())
|
|
52
52
|
.then(() => emitWatching(watchDirectory));
|
|
53
53
|
}
|
|
54
54
|
}, 100);
|
|
@@ -146,7 +146,7 @@ const createWatcher = (initialContext, onNext) => {
|
|
|
146
146
|
*/
|
|
147
147
|
stopWatching.runningWatcher = new Promise((resolve, reject) => {
|
|
148
148
|
(0, codegen_js_1.executeCodegen)(initialContext)
|
|
149
|
-
.then(onNext, () => Promise.resolve())
|
|
149
|
+
.then(({ result }) => onNext(result), () => Promise.resolve())
|
|
150
150
|
.then(() => runWatcher(abortController.signal))
|
|
151
151
|
.catch(err => {
|
|
152
152
|
watcherSubscription.unsubscribe();
|
package/esm/codegen.js
CHANGED
|
@@ -328,12 +328,12 @@ export async function executeCodegen(input) {
|
|
|
328
328
|
// if we have debug logs, make sure to print them before throwing the errors
|
|
329
329
|
printLogs();
|
|
330
330
|
}
|
|
331
|
+
let error = null;
|
|
331
332
|
if (executedContext.errors.length > 0) {
|
|
332
333
|
const errors = executedContext.errors.map(subErr => subErr.message || subErr.toString());
|
|
333
|
-
|
|
334
|
+
error = new AggregateError(executedContext.errors, String(errors.join('\n\n')));
|
|
334
335
|
// Best-effort to all stack traces for debugging
|
|
335
|
-
|
|
336
|
-
throw newErr;
|
|
336
|
+
error.stack = `${error.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
337
337
|
}
|
|
338
|
-
return result;
|
|
338
|
+
return { result, error };
|
|
339
339
|
}
|
package/esm/generate-and-save.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createHash } from 'crypto';
|
|
2
2
|
import { dirname, isAbsolute, join } from 'path';
|
|
3
|
+
import logSymbols from 'log-symbols';
|
|
3
4
|
import { executeCodegen } from './codegen.js';
|
|
4
5
|
import { ensureContext } from './config.js';
|
|
5
6
|
import { lifecycleHooks } from './hooks.js';
|
|
6
7
|
import { debugLog } from './utils/debugging.js';
|
|
7
8
|
import { mkdirp, readFile, unlinkFile, writeFile } from './utils/file-system.js';
|
|
8
9
|
import { createWatcher } from './utils/watcher.js';
|
|
10
|
+
import { getLogger } from './utils/logger.js';
|
|
9
11
|
const hash = (content) => createHash('sha1').update(content).digest('base64');
|
|
10
12
|
export async function generate(input, saveToFile = true) {
|
|
11
13
|
const context = ensureContext(input);
|
|
@@ -96,7 +98,16 @@ export async function generate(input, saveToFile = true) {
|
|
|
96
98
|
if (config.watch) {
|
|
97
99
|
return createWatcher(context, writeOutput).runningWatcher;
|
|
98
100
|
}
|
|
99
|
-
const outputFiles = await context.profiler.run(() => executeCodegen(context), 'executeCodegen');
|
|
101
|
+
const { result: outputFiles, error } = await context.profiler.run(() => executeCodegen(context), 'executeCodegen');
|
|
102
|
+
if (error) {
|
|
103
|
+
if (config.writeOnPartialSuccess) {
|
|
104
|
+
getLogger().warn(` ${logSymbols.warning} One or more errors occurred while generating files. Successful processes wrote output to files.`);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
getLogger().error(` ${logSymbols.error} One or more errors occurred while generating files. No output was written to files.`);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
100
111
|
await context.profiler.run(() => writeOutput(outputFiles), 'writeOutput');
|
|
101
112
|
await context.profiler.run(() => lifecycleHooks(config.hooks).beforeDone(), 'Lifecycle: beforeDone');
|
|
102
113
|
if (context.profilerOutput) {
|
package/esm/utils/watcher.js
CHANGED
|
@@ -44,7 +44,7 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
44
44
|
const debouncedExec = debounce(() => {
|
|
45
45
|
if (!isShutdown) {
|
|
46
46
|
executeCodegen(initialContext)
|
|
47
|
-
.then(onNext, () => Promise.resolve())
|
|
47
|
+
.then(({ result }) => onNext(result), () => Promise.resolve())
|
|
48
48
|
.then(() => emitWatching(watchDirectory));
|
|
49
49
|
}
|
|
50
50
|
}, 100);
|
|
@@ -142,7 +142,7 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
142
142
|
*/
|
|
143
143
|
stopWatching.runningWatcher = new Promise((resolve, reject) => {
|
|
144
144
|
executeCodegen(initialContext)
|
|
145
|
-
.then(onNext, () => Promise.resolve())
|
|
145
|
+
.then(({ result }) => onNext(result), () => Promise.resolve())
|
|
146
146
|
.then(() => runWatcher(abortController.signal))
|
|
147
147
|
.catch(err => {
|
|
148
148
|
watcherSubscription.unsubscribe();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha-20250627115156-9c57b83a4553fcece2f9fa6d83a61efd06c03b16",
|
|
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": "4.8.4-alpha-
|
|
18
|
-
"@graphql-codegen/core": "4.0.3-alpha-
|
|
19
|
-
"@graphql-codegen/plugin-helpers": "6.0.0-alpha-
|
|
17
|
+
"@graphql-codegen/client-preset": "4.8.4-alpha-20250627115156-9c57b83a4553fcece2f9fa6d83a61efd06c03b16",
|
|
18
|
+
"@graphql-codegen/core": "4.0.3-alpha-20250627115156-9c57b83a4553fcece2f9fa6d83a61efd06c03b16",
|
|
19
|
+
"@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250627115156-9c57b83a4553fcece2f9fa6d83a61efd06c03b16",
|
|
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/codegen.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { CodegenContext } from './config.cjs';
|
|
3
|
-
export declare function executeCodegen(input: CodegenContext | Types.Config): Promise<
|
|
3
|
+
export declare function executeCodegen(input: CodegenContext | Types.Config): Promise<{
|
|
4
|
+
result: Types.FileOutput[];
|
|
5
|
+
error: Error | null;
|
|
6
|
+
}>;
|
package/typings/codegen.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { CodegenContext } from './config.js';
|
|
3
|
-
export declare function executeCodegen(input: CodegenContext | Types.Config): Promise<
|
|
3
|
+
export declare function executeCodegen(input: CodegenContext | Types.Config): Promise<{
|
|
4
|
+
result: Types.FileOutput[];
|
|
5
|
+
error: Error | null;
|
|
6
|
+
}>;
|