UNPKG

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