@graphql-codegen/cli 2.11.4-alpha-20220804125427-dc9183b8a → 2.11.5-alpha-20220808101014-dcd7a85a5
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 -3
- package/cjs/load.js +1 -2
- package/esm/codegen.js +4 -3
- package/esm/load.js +1 -2
- package/package.json +5 -5
- package/typings/bin.d.cts +2 -0
- package/typings/cli.d.cts +2 -0
- package/typings/codegen.d.cts +3 -0
- package/typings/config.d.cts +138 -0
- package/typings/generate-and-save.d.cts +5 -0
- package/typings/graphql-config.d.cts +3 -0
- package/typings/hooks.d.cts +11 -0
- package/typings/index.d.cts +7 -0
- package/typings/init/helpers.d.cts +10 -0
- package/typings/init/index.d.cts +1 -0
- package/typings/init/plugins.d.cts +2 -0
- package/typings/init/questions.d.cts +11 -0
- package/typings/init/targets.d.cts +2 -0
- package/typings/init/types.d.cts +29 -0
- package/typings/load.d.cts +15 -0
- package/typings/plugins.d.cts +2 -0
- package/typings/presets.d.cts +5 -0
- package/typings/utils/cli-error.d.cts +11 -0
- package/typings/utils/debugging.d.cts +3 -0
- package/typings/utils/file-system.d.cts +4 -0
- package/typings/utils/get-latest-version.d.cts +6 -0
- package/typings/utils/logger.d.cts +5 -0
- package/typings/utils/watcher.d.cts +3 -0
package/cjs/codegen.js
CHANGED
|
@@ -310,6 +310,10 @@ async function executeCodegen(input) {
|
|
|
310
310
|
// All the errors throw in `listr2` are collected in context
|
|
311
311
|
// Running tasks doesn't throw anything
|
|
312
312
|
const executedContext = await tasks.run();
|
|
313
|
+
if (config.debug) {
|
|
314
|
+
// if we have debug logs, make sure to print them before throwing the errors
|
|
315
|
+
(0, debugging_js_1.printLogs)();
|
|
316
|
+
}
|
|
313
317
|
if (executedContext.errors.length > 0) {
|
|
314
318
|
const errors = executedContext.errors.map(subErr => (0, plugin_helpers_1.isDetailedError)(subErr)
|
|
315
319
|
? `${subErr.message} for "${subErr.source}"${subErr.details}`
|
|
@@ -319,9 +323,6 @@ async function executeCodegen(input) {
|
|
|
319
323
|
newErr.stack = `${newErr.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
320
324
|
throw newErr;
|
|
321
325
|
}
|
|
322
|
-
if (config.debug) {
|
|
323
|
-
(0, debugging_js_1.printLogs)();
|
|
324
|
-
}
|
|
325
326
|
return result;
|
|
326
327
|
}
|
|
327
328
|
exports.executeCodegen = executeCodegen;
|
package/cjs/load.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadDocuments = exports.loadSchema = exports.defaultDocumentsLoadOptions = exports.defaultSchemaLoadOptions = void 0;
|
|
4
4
|
const load_1 = require("@graphql-tools/load");
|
|
5
|
-
const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
|
|
6
5
|
const code_file_loader_1 = require("@graphql-tools/code-file-loader");
|
|
7
6
|
const git_loader_1 = require("@graphql-tools/git-loader");
|
|
8
7
|
const github_loader_1 = require("@graphql-tools/github-loader");
|
|
@@ -43,7 +42,7 @@ async function loadSchema(schemaPointers, config) {
|
|
|
43
42
|
return schema;
|
|
44
43
|
}
|
|
45
44
|
catch (e) {
|
|
46
|
-
throw new
|
|
45
|
+
throw new Error(`
|
|
47
46
|
Failed to load schema from ${Object.keys(schemaPointers).join(',')}:
|
|
48
47
|
|
|
49
48
|
${e.message || e}
|
package/esm/codegen.js
CHANGED
|
@@ -306,6 +306,10 @@ export async function executeCodegen(input) {
|
|
|
306
306
|
// All the errors throw in `listr2` are collected in context
|
|
307
307
|
// Running tasks doesn't throw anything
|
|
308
308
|
const executedContext = await tasks.run();
|
|
309
|
+
if (config.debug) {
|
|
310
|
+
// if we have debug logs, make sure to print them before throwing the errors
|
|
311
|
+
printLogs();
|
|
312
|
+
}
|
|
309
313
|
if (executedContext.errors.length > 0) {
|
|
310
314
|
const errors = executedContext.errors.map(subErr => isDetailedError(subErr)
|
|
311
315
|
? `${subErr.message} for "${subErr.source}"${subErr.details}`
|
|
@@ -315,8 +319,5 @@ export async function executeCodegen(input) {
|
|
|
315
319
|
newErr.stack = `${newErr.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
316
320
|
throw newErr;
|
|
317
321
|
}
|
|
318
|
-
if (config.debug) {
|
|
319
|
-
printLogs();
|
|
320
|
-
}
|
|
321
322
|
return result;
|
|
322
323
|
}
|
package/esm/load.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { loadSchema as loadSchemaToolkit, loadDocuments as loadDocumentsToolkit, } from '@graphql-tools/load';
|
|
2
|
-
import { DetailedError } from '@graphql-codegen/plugin-helpers';
|
|
3
2
|
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
|
|
4
3
|
import { GitLoader } from '@graphql-tools/git-loader';
|
|
5
4
|
import { GithubLoader } from '@graphql-tools/github-loader';
|
|
@@ -40,7 +39,7 @@ export async function loadSchema(schemaPointers, config) {
|
|
|
40
39
|
return schema;
|
|
41
40
|
}
|
|
42
41
|
catch (e) {
|
|
43
|
-
throw new
|
|
42
|
+
throw new Error(`
|
|
44
43
|
Failed to load schema from ${Object.keys(schemaPointers).join(',')}:
|
|
45
44
|
|
|
46
45
|
${e.message || e}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.5-alpha-20220808101014-dcd7a85a5",
|
|
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
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@graphql-codegen/core": "2.6.
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "^2.6.
|
|
8
|
+
"@graphql-codegen/core": "2.6.1",
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^2.6.2",
|
|
10
10
|
"@graphql-tools/apollo-engine-loader": "^7.3.6",
|
|
11
11
|
"@graphql-tools/code-file-loader": "^7.3.1",
|
|
12
12
|
"@graphql-tools/git-loader": "^7.2.1",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@graphql-tools/utils": "^8.9.0",
|
|
20
20
|
"@whatwg-node/fetch": "^0.2.3",
|
|
21
21
|
"ansi-escapes": "^4.3.1",
|
|
22
|
-
"chalk": "^4",
|
|
22
|
+
"chalk": "^4.1.0",
|
|
23
23
|
"chokidar": "^3.5.2",
|
|
24
24
|
"cosmiconfig": "^7.0.0",
|
|
25
25
|
"debounce": "^1.2.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"exports": {
|
|
73
73
|
".": {
|
|
74
74
|
"require": {
|
|
75
|
-
"types": "./typings/index.d.
|
|
75
|
+
"types": "./typings/index.d.cts",
|
|
76
76
|
"default": "./cjs/index.js"
|
|
77
77
|
},
|
|
78
78
|
"import": {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Types, Profiler } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
import { GraphQLConfig } from 'graphql-config';
|
|
3
|
+
import { GraphQLSchema } from 'graphql';
|
|
4
|
+
export declare type YamlCliFlags = {
|
|
5
|
+
config: string;
|
|
6
|
+
watch: boolean | string | string[];
|
|
7
|
+
require: string[];
|
|
8
|
+
overwrite: boolean;
|
|
9
|
+
project: string;
|
|
10
|
+
silent: boolean;
|
|
11
|
+
errorsOnly: boolean;
|
|
12
|
+
profile: boolean;
|
|
13
|
+
check?: boolean;
|
|
14
|
+
verbose?: boolean;
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
ignoreNoDocuments?: boolean;
|
|
17
|
+
emitLegacyCommonJSImports?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function generateSearchPlaces(moduleName: string): string[];
|
|
20
|
+
export interface LoadCodegenConfigOptions {
|
|
21
|
+
/**
|
|
22
|
+
* The path to the config file or directory contains the config file.
|
|
23
|
+
* @default process.cwd()
|
|
24
|
+
*/
|
|
25
|
+
configFilePath?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The name of the config file
|
|
28
|
+
* @default codegen
|
|
29
|
+
*/
|
|
30
|
+
moduleName?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Additional search paths for the config file you want to check
|
|
33
|
+
*/
|
|
34
|
+
searchPlaces?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* @default codegen
|
|
37
|
+
*/
|
|
38
|
+
packageProp?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Overrides or extends the loaders for specific file extensions
|
|
41
|
+
*/
|
|
42
|
+
loaders?: Record<string, (filepath: string, content: string) => Promise<Types.Config> | Types.Config>;
|
|
43
|
+
}
|
|
44
|
+
export interface LoadCodegenConfigResult {
|
|
45
|
+
filepath: string;
|
|
46
|
+
config: Types.Config;
|
|
47
|
+
isEmpty?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare function loadCodegenConfig({ configFilePath, moduleName, searchPlaces: additionalSearchPlaces, packageProp, loaders: customLoaders, }: LoadCodegenConfigOptions): Promise<LoadCodegenConfigResult>;
|
|
50
|
+
export declare function loadContext(configFilePath?: string): Promise<CodegenContext> | never;
|
|
51
|
+
export declare function buildOptions(): {
|
|
52
|
+
c: {
|
|
53
|
+
alias: string;
|
|
54
|
+
type: "string";
|
|
55
|
+
describe: string;
|
|
56
|
+
};
|
|
57
|
+
w: {
|
|
58
|
+
alias: string;
|
|
59
|
+
describe: string;
|
|
60
|
+
coerce: (watch: any) => string | boolean | any[];
|
|
61
|
+
};
|
|
62
|
+
r: {
|
|
63
|
+
alias: string;
|
|
64
|
+
describe: string;
|
|
65
|
+
type: "array";
|
|
66
|
+
default: any[];
|
|
67
|
+
};
|
|
68
|
+
o: {
|
|
69
|
+
alias: string;
|
|
70
|
+
describe: string;
|
|
71
|
+
type: "boolean";
|
|
72
|
+
};
|
|
73
|
+
s: {
|
|
74
|
+
alias: string;
|
|
75
|
+
describe: string;
|
|
76
|
+
type: "boolean";
|
|
77
|
+
};
|
|
78
|
+
e: {
|
|
79
|
+
alias: string;
|
|
80
|
+
describe: string;
|
|
81
|
+
type: "boolean";
|
|
82
|
+
};
|
|
83
|
+
profile: {
|
|
84
|
+
describe: string;
|
|
85
|
+
type: "boolean";
|
|
86
|
+
};
|
|
87
|
+
p: {
|
|
88
|
+
alias: string;
|
|
89
|
+
describe: string;
|
|
90
|
+
type: "string";
|
|
91
|
+
};
|
|
92
|
+
v: {
|
|
93
|
+
alias: string;
|
|
94
|
+
describe: string;
|
|
95
|
+
type: "boolean";
|
|
96
|
+
default: boolean;
|
|
97
|
+
};
|
|
98
|
+
d: {
|
|
99
|
+
alias: string;
|
|
100
|
+
describe: string;
|
|
101
|
+
type: "boolean";
|
|
102
|
+
default: boolean;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export declare function parseArgv(argv?: string[]): YamlCliFlags;
|
|
106
|
+
export declare function createContext(cliFlags?: YamlCliFlags): Promise<CodegenContext>;
|
|
107
|
+
export declare function updateContextWithCliFlags(context: CodegenContext, cliFlags: YamlCliFlags): void;
|
|
108
|
+
export declare class CodegenContext {
|
|
109
|
+
private _config;
|
|
110
|
+
private _graphqlConfig?;
|
|
111
|
+
private config;
|
|
112
|
+
private _project?;
|
|
113
|
+
private _checkMode;
|
|
114
|
+
private _pluginContext;
|
|
115
|
+
cwd: string;
|
|
116
|
+
filepath: string;
|
|
117
|
+
profiler: Profiler;
|
|
118
|
+
profilerOutput?: string;
|
|
119
|
+
checkModeStaleFiles: any[];
|
|
120
|
+
constructor({ config, graphqlConfig, filepath, }: {
|
|
121
|
+
config?: Types.Config;
|
|
122
|
+
graphqlConfig?: GraphQLConfig;
|
|
123
|
+
filepath?: string;
|
|
124
|
+
});
|
|
125
|
+
useProject(name?: string): void;
|
|
126
|
+
getConfig<T>(extraConfig?: T): T & Types.Config;
|
|
127
|
+
updateConfig(config: Partial<Types.Config>): void;
|
|
128
|
+
enableCheckMode(): void;
|
|
129
|
+
get checkMode(): boolean;
|
|
130
|
+
useProfiler(): void;
|
|
131
|
+
getPluginContext(): {
|
|
132
|
+
[key: string]: any;
|
|
133
|
+
};
|
|
134
|
+
loadSchema(pointer: Types.Schema): Promise<GraphQLSchema>;
|
|
135
|
+
loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
|
|
136
|
+
}
|
|
137
|
+
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|
|
138
|
+
export declare function shouldEmitLegacyCommonJSImports(config: Types.Config, outputPath: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
export declare const lifecycleHooks: (_hooks?: Partial<Types.LifecycleHooksDefinition>) => {
|
|
3
|
+
afterStart: () => Promise<void>;
|
|
4
|
+
onWatchTriggered: (event: string, path: string) => Promise<void>;
|
|
5
|
+
onError: (error: string) => Promise<void>;
|
|
6
|
+
afterOneFileWrite: (path: string) => Promise<void>;
|
|
7
|
+
afterAllFileWrite: (paths: string[]) => Promise<void>;
|
|
8
|
+
beforeOneFileWrite: (path: string) => Promise<void>;
|
|
9
|
+
beforeAllFileWrite: (paths: string[]) => Promise<void>;
|
|
10
|
+
beforeDone: () => Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { executeCodegen } from './codegen.cjs';
|
|
2
|
+
export { generate } from './generate-and-save.cjs';
|
|
3
|
+
export * from './config.cjs';
|
|
4
|
+
export * from './init/index.cjs';
|
|
5
|
+
export * from './utils/cli-error.cjs';
|
|
6
|
+
export * from './cli.cjs';
|
|
7
|
+
export * from './graphql-config.cjs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
import { Answers } from './types.cjs';
|
|
3
|
+
export declare function writeConfig(answers: Answers, config: Types.Config): Promise<{
|
|
4
|
+
relativePath: string;
|
|
5
|
+
fullPath: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function writePackage(answers: Answers, configLocation: string): Promise<void>;
|
|
8
|
+
export declare function bold(str: string): string;
|
|
9
|
+
export declare function grey(str: string): string;
|
|
10
|
+
export declare function italic(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function init(): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { Tags, Answers } from './types.cjs';
|
|
3
|
+
export declare function getQuestions(possibleTargets: Record<Tags, boolean>): inquirer.QuestionCollection;
|
|
4
|
+
export declare function getApplicationTypeChoices(possibleTargets: Record<Tags, boolean>): {
|
|
5
|
+
name: string;
|
|
6
|
+
key: string;
|
|
7
|
+
value: Tags[];
|
|
8
|
+
checked: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
export declare function getPluginChoices(answers: Answers): inquirer.DistinctChoice<inquirer.AllChoiceMap<inquirer.Answers>, inquirer.AllChoiceMap<inquirer.AllChoiceMap<inquirer.Answers>>>[];
|
|
11
|
+
export declare function getOutputDefaultValue(answers: Answers): "src/generated/graphql.tsx" | "src/generated/graphql.ts" | "src/generated/graphql.cjs";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface PluginOption {
|
|
2
|
+
name: string;
|
|
3
|
+
package: string;
|
|
4
|
+
value: string;
|
|
5
|
+
pathInRepo: string;
|
|
6
|
+
available(tags: Tags[]): boolean;
|
|
7
|
+
shouldBeSelected(tags: Tags[]): boolean;
|
|
8
|
+
defaultExtension: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Answers {
|
|
11
|
+
targets: Tags[];
|
|
12
|
+
config: string;
|
|
13
|
+
plugins: PluginOption[];
|
|
14
|
+
schema: string;
|
|
15
|
+
documents?: string;
|
|
16
|
+
output: string;
|
|
17
|
+
script: string;
|
|
18
|
+
introspection: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare enum Tags {
|
|
21
|
+
browser = "Browser",
|
|
22
|
+
node = "Node",
|
|
23
|
+
typescript = "TypeScript",
|
|
24
|
+
flow = "Flow",
|
|
25
|
+
angular = "Angular",
|
|
26
|
+
stencil = "Stencil",
|
|
27
|
+
react = "React",
|
|
28
|
+
vue = "Vue"
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UnnormalizedTypeDefPointer } from '@graphql-tools/load';
|
|
2
|
+
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
3
|
+
import { GraphQLSchema } from 'graphql';
|
|
4
|
+
export declare const defaultSchemaLoadOptions: {
|
|
5
|
+
assumeValidSDL: boolean;
|
|
6
|
+
sort: boolean;
|
|
7
|
+
convertExtensions: boolean;
|
|
8
|
+
includeSources: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const defaultDocumentsLoadOptions: {
|
|
11
|
+
sort: boolean;
|
|
12
|
+
skipGraphQLImport: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function loadSchema(schemaPointers: UnnormalizedTypeDefPointer, config: Types.Config): Promise<GraphQLSchema>;
|
|
15
|
+
export declare function loadDocuments(documentPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], config: Types.Config): Promise<Types.DocumentFile[]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DetailedError } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
declare type CompositeError = Error | DetailedError;
|
|
3
|
+
declare type ListrError = Error & {
|
|
4
|
+
errors: CompositeError[];
|
|
5
|
+
};
|
|
6
|
+
export declare function isListrError(err: Error & {
|
|
7
|
+
name?: unknown;
|
|
8
|
+
errors?: unknown;
|
|
9
|
+
}): err is ListrError;
|
|
10
|
+
export declare function cliError(err: any, exitOnError?: boolean): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function writeFile(filepath: string, content: string): Promise<void>;
|
|
2
|
+
export declare function readFile(filepath: string): Promise<string>;
|
|
3
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
4
|
+
export declare function unlinkFile(filePath: string, cb?: (err?: Error) => any): void;
|