UNPKG

4.17 kBTypeScriptView Raw
1import { Profiler, Types } from '@graphql-codegen/plugin-helpers';
2import { GraphQLSchema } from 'graphql';
3import { GraphQLConfig } from 'graphql-config';
4export type CodegenConfig = Types.Config;
5export type YamlCliFlags = {
6 config: string;
7 watch: boolean | string | string[];
8 require: string[];
9 overwrite: boolean;
10 project: string;
11 silent: boolean;
12 errorsOnly: boolean;
13 profile: boolean;
14 check?: boolean;
15 verbose?: boolean;
16 debug?: boolean;
17 ignoreNoDocuments?: boolean;
18 emitLegacyCommonJSImports?: boolean;
19};
20export declare function generateSearchPlaces(moduleName: string): string[];
21export type CodegenConfigLoader = (filepath: string, content: string) => Promise<Types.Config> | Types.Config;
22export interface LoadCodegenConfigOptions {
23 /**
24 * The path to the config file or directory contains the config file.
25 * @default process.cwd()
26 */
27 configFilePath?: string;
28 /**
29 * The name of the config file
30 * @default codegen
31 */
32 moduleName?: string;
33 /**
34 * Additional search paths for the config file you want to check
35 */
36 searchPlaces?: string[];
37 /**
38 * @default codegen
39 */
40 packageProp?: string;
41 /**
42 * Overrides or extends the loaders for specific file extensions
43 */
44 loaders?: Record<string, CodegenConfigLoader>;
45}
46export interface LoadCodegenConfigResult {
47 filepath: string;
48 config: Types.Config;
49 isEmpty?: boolean;
50}
51export declare function loadCodegenConfig({ configFilePath, moduleName, searchPlaces: additionalSearchPlaces, packageProp, loaders: customLoaders, }: LoadCodegenConfigOptions): Promise<LoadCodegenConfigResult>;
52export declare function loadContext(configFilePath?: string): Promise<CodegenContext> | never;
53export declare function buildOptions(): {
54 c: {
55 alias: string;
56 type: "string";
57 describe: string;
58 };
59 w: {
60 alias: string;
61 describe: string;
62 coerce(watch: any): string | boolean | any[];
63 };
64 r: {
65 alias: string;
66 describe: string;
67 type: "array";
68 default: any[];
69 };
70 o: {
71 alias: string;
72 describe: string;
73 type: "boolean";
74 };
75 s: {
76 alias: string;
77 describe: string;
78 type: "boolean";
79 };
80 e: {
81 alias: string;
82 describe: string;
83 type: "boolean";
84 };
85 profile: {
86 describe: string;
87 type: "boolean";
88 };
89 p: {
90 alias: string;
91 describe: string;
92 type: "string";
93 };
94 v: {
95 alias: string;
96 describe: string;
97 type: "boolean";
98 default: boolean;
99 };
100 d: {
101 alias: string;
102 describe: string;
103 type: "boolean";
104 default: boolean;
105 };
106};
107export declare function parseArgv(argv?: string[]): YamlCliFlags;
108export declare function createContext(cliFlags?: YamlCliFlags): Promise<CodegenContext>;
109export declare function updateContextWithCliFlags(context: CodegenContext, cliFlags: YamlCliFlags): void;
110export declare class CodegenContext {
111 private _config;
112 private _graphqlConfig?;
113 private config;
114 private _project?;
115 private _checkMode;
116 private _pluginContext;
117 cwd: string;
118 filepath: string;
119 profiler: Profiler;
120 profilerOutput?: string;
121 checkModeStaleFiles: any[];
122 constructor({ config, graphqlConfig, filepath, }: {
123 config?: Types.Config;
124 graphqlConfig?: GraphQLConfig;
125 filepath?: string;
126 });
127 useProject(name?: string): void;
128 getConfig<T>(extraConfig?: T): T & Types.Config;
129 updateConfig(config: Partial<Types.Config>): void;
130 enableCheckMode(): void;
131 get checkMode(): boolean;
132 useProfiler(): void;
133 getPluginContext(): {
134 [key: string]: any;
135 };
136 loadSchema(pointer: Types.Schema): Promise<GraphQLSchema>;
137 loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
138}
139export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
140export declare function shouldEmitLegacyCommonJSImports(config: Types.Config): boolean;