UNPKG

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