@graphql-codegen/cli 2.13.7 → 2.13.8-alpha-20221025131227-aee11a778
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/cli.js +5 -7
- package/cjs/codegen.js +5 -8
- package/cjs/config.js +3 -3
- package/cjs/plugins.js +2 -3
- package/esm/cli.js +5 -7
- package/esm/codegen.js +6 -9
- package/esm/config.js +4 -4
- package/esm/plugins.js +2 -3
- package/package.json +3 -3
- package/typings/utils/cli-error.d.cts +1 -2
- package/typings/utils/cli-error.d.ts +1 -2
package/cjs/cli.js
CHANGED
|
@@ -28,7 +28,6 @@ const generate_and_save_js_1 = require("./generate-and-save.js");
|
|
|
28
28
|
const index_js_1 = require("./init/index.js");
|
|
29
29
|
const config_js_1 = require("./config.js");
|
|
30
30
|
const hooks_js_1 = require("./hooks.js");
|
|
31
|
-
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
32
31
|
async function runCli(cmd) {
|
|
33
32
|
await ensureGraphQlPackage();
|
|
34
33
|
if (cmd === 'init') {
|
|
@@ -56,12 +55,11 @@ async function ensureGraphQlPackage() {
|
|
|
56
55
|
await Promise.resolve().then(() => __importStar(require('graphql')));
|
|
57
56
|
}
|
|
58
57
|
catch (e) {
|
|
59
|
-
throw new
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
`);
|
|
58
|
+
throw new Error(`Unable to load "graphql" package. Please make sure to install "graphql" as a dependency! \n
|
|
59
|
+
To install "graphql", run:
|
|
60
|
+
yarn add graphql
|
|
61
|
+
Or, with NPM:
|
|
62
|
+
npm install --save graphql`);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
exports.ensureGraphQlPackage = ensureGraphQlPackage;
|
package/cjs/codegen.js
CHANGED
|
@@ -92,7 +92,7 @@ async function executeCodegen(input) {
|
|
|
92
92
|
/* Normalize "generators" field */
|
|
93
93
|
const generateKeys = Object.keys(config.generates || {});
|
|
94
94
|
if (generateKeys.length === 0) {
|
|
95
|
-
throw new
|
|
95
|
+
throw new Error(`Invalid Codegen Configuration! \n
|
|
96
96
|
Please make sure that your codegen config file contains the "generates" field, with a specification for the plugins you need.
|
|
97
97
|
|
|
98
98
|
It should looks like that:
|
|
@@ -103,13 +103,12 @@ async function executeCodegen(input) {
|
|
|
103
103
|
my-file.ts:
|
|
104
104
|
- plugin1
|
|
105
105
|
- plugin2
|
|
106
|
-
- plugin3
|
|
107
|
-
`);
|
|
106
|
+
- plugin3`);
|
|
108
107
|
}
|
|
109
108
|
for (const filename of generateKeys) {
|
|
110
109
|
const output = (generates[filename] = (0, plugin_helpers_1.normalizeOutputParam)(config.generates[filename]));
|
|
111
110
|
if (!output.preset && (!output.plugins || output.plugins.length === 0)) {
|
|
112
|
-
throw new
|
|
111
|
+
throw new Error(`Invalid Codegen Configuration! \n
|
|
113
112
|
Please make sure that your codegen config file has defined plugins list for output "${filename}".
|
|
114
113
|
|
|
115
114
|
It should looks like that:
|
|
@@ -128,7 +127,7 @@ async function executeCodegen(input) {
|
|
|
128
127
|
Object.keys(generates).some(filename => !generates[filename].schema ||
|
|
129
128
|
(Array.isArray(generates[filename].schema === 'object') &&
|
|
130
129
|
generates[filename].schema.length === 0))) {
|
|
131
|
-
throw new
|
|
130
|
+
throw new Error(`Invalid Codegen Configuration! \n
|
|
132
131
|
Please make sure that your codegen config file contains either the "schema" field
|
|
133
132
|
or every generated file has its own "schema" field.
|
|
134
133
|
|
|
@@ -320,9 +319,7 @@ async function executeCodegen(input) {
|
|
|
320
319
|
(0, debugging_js_1.printLogs)();
|
|
321
320
|
}
|
|
322
321
|
if (executedContext.errors.length > 0) {
|
|
323
|
-
const errors = executedContext.errors.map(subErr =>
|
|
324
|
-
? `${subErr.message} for "${subErr.source}"${subErr.details}`
|
|
325
|
-
: subErr.message || subErr.toString());
|
|
322
|
+
const errors = executedContext.errors.map(subErr => subErr.message || subErr.toString());
|
|
326
323
|
const newErr = new utils_1.AggregateError(executedContext.errors, `${errors.join('\n\n')}`);
|
|
327
324
|
// Best-effort to all stack traces for debugging
|
|
328
325
|
newErr.stack = `${newErr.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
package/cjs/config.js
CHANGED
|
@@ -85,7 +85,7 @@ async function loadContext(configFilePath) {
|
|
|
85
85
|
const result = await loadCodegenConfig({ configFilePath });
|
|
86
86
|
if (!result) {
|
|
87
87
|
if (configFilePath) {
|
|
88
|
-
throw new
|
|
88
|
+
throw new Error(`
|
|
89
89
|
Config ${configFilePath} does not exist.
|
|
90
90
|
|
|
91
91
|
$ graphql-codegen --config ${configFilePath}
|
|
@@ -93,12 +93,12 @@ async function loadContext(configFilePath) {
|
|
|
93
93
|
Please make sure the --config points to a correct file.
|
|
94
94
|
`);
|
|
95
95
|
}
|
|
96
|
-
throw new
|
|
96
|
+
throw new Error(`Unable to find Codegen config file! \n
|
|
97
97
|
Please make sure that you have a configuration file under the current directory!
|
|
98
98
|
`);
|
|
99
99
|
}
|
|
100
100
|
if (result.isEmpty) {
|
|
101
|
-
throw new
|
|
101
|
+
throw new Error(`Found Codegen config file but it was empty! \n
|
|
102
102
|
Please make sure that you have a valid configuration file under the current directory!
|
|
103
103
|
`);
|
|
104
104
|
}
|
package/cjs/plugins.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPluginByName = void 0;
|
|
4
|
-
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
5
4
|
const path_1 = require("path");
|
|
6
5
|
async function getPluginByName(name, pluginLoader) {
|
|
7
6
|
const possibleNames = [
|
|
@@ -22,7 +21,7 @@ async function getPluginByName(name, pluginLoader) {
|
|
|
22
21
|
}
|
|
23
22
|
catch (err) {
|
|
24
23
|
if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ERR_MODULE_NOT_FOUND') {
|
|
25
|
-
throw new
|
|
24
|
+
throw new Error(`
|
|
26
25
|
Unable to load template plugin matching '${name}'.
|
|
27
26
|
Reason:
|
|
28
27
|
${err.message}
|
|
@@ -35,7 +34,7 @@ async function getPluginByName(name, pluginLoader) {
|
|
|
35
34
|
- ${name}
|
|
36
35
|
`.trimRight())
|
|
37
36
|
.join('');
|
|
38
|
-
throw new
|
|
37
|
+
throw new Error(`
|
|
39
38
|
Unable to find template plugin matching '${name}'
|
|
40
39
|
Install one of the following packages:
|
|
41
40
|
|
package/esm/cli.js
CHANGED
|
@@ -2,7 +2,6 @@ import { generate } from './generate-and-save.js';
|
|
|
2
2
|
import { init } from './init/index.js';
|
|
3
3
|
import { createContext } from './config.js';
|
|
4
4
|
import { lifecycleHooks } from './hooks.js';
|
|
5
|
-
import { DetailedError } from '@graphql-codegen/plugin-helpers';
|
|
6
5
|
export async function runCli(cmd) {
|
|
7
6
|
await ensureGraphQlPackage();
|
|
8
7
|
if (cmd === 'init') {
|
|
@@ -29,11 +28,10 @@ export async function ensureGraphQlPackage() {
|
|
|
29
28
|
await import('graphql');
|
|
30
29
|
}
|
|
31
30
|
catch (e) {
|
|
32
|
-
throw new
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`);
|
|
31
|
+
throw new Error(`Unable to load "graphql" package. Please make sure to install "graphql" as a dependency! \n
|
|
32
|
+
To install "graphql", run:
|
|
33
|
+
yarn add graphql
|
|
34
|
+
Or, with NPM:
|
|
35
|
+
npm install --save graphql`);
|
|
38
36
|
}
|
|
39
37
|
}
|
package/esm/codegen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeOutputParam, normalizeInstanceOrArray, normalizeConfig, getCachedDocumentNodeFromSchema, } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { codegen } from '@graphql-codegen/core';
|
|
3
3
|
import { AggregateError } from '@graphql-tools/utils';
|
|
4
4
|
import { GraphQLError } from 'graphql';
|
|
@@ -88,7 +88,7 @@ export async function executeCodegen(input) {
|
|
|
88
88
|
/* Normalize "generators" field */
|
|
89
89
|
const generateKeys = Object.keys(config.generates || {});
|
|
90
90
|
if (generateKeys.length === 0) {
|
|
91
|
-
throw new
|
|
91
|
+
throw new Error(`Invalid Codegen Configuration! \n
|
|
92
92
|
Please make sure that your codegen config file contains the "generates" field, with a specification for the plugins you need.
|
|
93
93
|
|
|
94
94
|
It should looks like that:
|
|
@@ -99,13 +99,12 @@ export async function executeCodegen(input) {
|
|
|
99
99
|
my-file.ts:
|
|
100
100
|
- plugin1
|
|
101
101
|
- plugin2
|
|
102
|
-
- plugin3
|
|
103
|
-
`);
|
|
102
|
+
- plugin3`);
|
|
104
103
|
}
|
|
105
104
|
for (const filename of generateKeys) {
|
|
106
105
|
const output = (generates[filename] = normalizeOutputParam(config.generates[filename]));
|
|
107
106
|
if (!output.preset && (!output.plugins || output.plugins.length === 0)) {
|
|
108
|
-
throw new
|
|
107
|
+
throw new Error(`Invalid Codegen Configuration! \n
|
|
109
108
|
Please make sure that your codegen config file has defined plugins list for output "${filename}".
|
|
110
109
|
|
|
111
110
|
It should looks like that:
|
|
@@ -124,7 +123,7 @@ export async function executeCodegen(input) {
|
|
|
124
123
|
Object.keys(generates).some(filename => !generates[filename].schema ||
|
|
125
124
|
(Array.isArray(generates[filename].schema === 'object') &&
|
|
126
125
|
generates[filename].schema.length === 0))) {
|
|
127
|
-
throw new
|
|
126
|
+
throw new Error(`Invalid Codegen Configuration! \n
|
|
128
127
|
Please make sure that your codegen config file contains either the "schema" field
|
|
129
128
|
or every generated file has its own "schema" field.
|
|
130
129
|
|
|
@@ -316,9 +315,7 @@ export async function executeCodegen(input) {
|
|
|
316
315
|
printLogs();
|
|
317
316
|
}
|
|
318
317
|
if (executedContext.errors.length > 0) {
|
|
319
|
-
const errors = executedContext.errors.map(subErr =>
|
|
320
|
-
? `${subErr.message} for "${subErr.source}"${subErr.details}`
|
|
321
|
-
: subErr.message || subErr.toString());
|
|
318
|
+
const errors = executedContext.errors.map(subErr => subErr.message || subErr.toString());
|
|
322
319
|
const newErr = new AggregateError(executedContext.errors, `${errors.join('\n\n')}`);
|
|
323
320
|
// Best-effort to all stack traces for debugging
|
|
324
321
|
newErr.stack = `${newErr.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
package/esm/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
|
|
2
2
|
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
|
-
import {
|
|
4
|
+
import { createProfiler, createNoopProfiler, getCachedDocumentNodeFromSchema, } from '@graphql-codegen/plugin-helpers';
|
|
5
5
|
import { env } from 'string-env-interpolation';
|
|
6
6
|
import yargs from 'yargs';
|
|
7
7
|
import { findAndLoadGraphQLConfig } from './graphql-config.js';
|
|
@@ -79,7 +79,7 @@ export async function loadContext(configFilePath) {
|
|
|
79
79
|
const result = await loadCodegenConfig({ configFilePath });
|
|
80
80
|
if (!result) {
|
|
81
81
|
if (configFilePath) {
|
|
82
|
-
throw new
|
|
82
|
+
throw new Error(`
|
|
83
83
|
Config ${configFilePath} does not exist.
|
|
84
84
|
|
|
85
85
|
$ graphql-codegen --config ${configFilePath}
|
|
@@ -87,12 +87,12 @@ export async function loadContext(configFilePath) {
|
|
|
87
87
|
Please make sure the --config points to a correct file.
|
|
88
88
|
`);
|
|
89
89
|
}
|
|
90
|
-
throw new
|
|
90
|
+
throw new Error(`Unable to find Codegen config file! \n
|
|
91
91
|
Please make sure that you have a configuration file under the current directory!
|
|
92
92
|
`);
|
|
93
93
|
}
|
|
94
94
|
if (result.isEmpty) {
|
|
95
|
-
throw new
|
|
95
|
+
throw new Error(`Found Codegen config file but it was empty! \n
|
|
96
96
|
Please make sure that you have a valid configuration file under the current directory!
|
|
97
97
|
`);
|
|
98
98
|
}
|
package/esm/plugins.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DetailedError } from '@graphql-codegen/plugin-helpers';
|
|
2
1
|
import { resolve } from 'path';
|
|
3
2
|
export async function getPluginByName(name, pluginLoader) {
|
|
4
3
|
const possibleNames = [
|
|
@@ -19,7 +18,7 @@ export async function getPluginByName(name, pluginLoader) {
|
|
|
19
18
|
}
|
|
20
19
|
catch (err) {
|
|
21
20
|
if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ERR_MODULE_NOT_FOUND') {
|
|
22
|
-
throw new
|
|
21
|
+
throw new Error(`
|
|
23
22
|
Unable to load template plugin matching '${name}'.
|
|
24
23
|
Reason:
|
|
25
24
|
${err.message}
|
|
@@ -32,7 +31,7 @@ export async function getPluginByName(name, pluginLoader) {
|
|
|
32
31
|
- ${name}
|
|
33
32
|
`.trimRight())
|
|
34
33
|
.join('');
|
|
35
|
-
throw new
|
|
34
|
+
throw new Error(`
|
|
36
35
|
Unable to find template plugin matching '${name}'
|
|
37
36
|
Install one of the following packages:
|
|
38
37
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.8-alpha-20221025131227-aee11a778",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
6
6
|
},
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"@babel/generator": "^7.18.13",
|
|
9
9
|
"@babel/template": "^7.18.10",
|
|
10
10
|
"@babel/types": "^7.18.13",
|
|
11
|
-
"@graphql-codegen/core": "2.6.
|
|
12
|
-
"@graphql-codegen/plugin-helpers": "
|
|
11
|
+
"@graphql-codegen/core": "2.6.3-alpha-20221025131227-aee11a778",
|
|
12
|
+
"@graphql-codegen/plugin-helpers": "2.7.2-alpha-20221025131227-aee11a778",
|
|
13
13
|
"@graphql-tools/apollo-engine-loader": "^7.3.6",
|
|
14
14
|
"@graphql-tools/code-file-loader": "^7.3.1",
|
|
15
15
|
"@graphql-tools/git-loader": "^7.2.1",
|