UNPKG

4.25 kBTypeScriptView Raw
1export declare type ModulesConfig = {
2 /**
3 * @name baseTypesPath
4 * @type string
5 * @description Required, should point to the base schema types file.
6 * The key of the output is used a base path for this file.
7 *
8 * @example
9 * ```ts filename="codegen.ts" {10}
10 * import type { CodegenConfig } from '@graphql-codegen/cli';
11 *
12 * const config: CodegenConfig = {
13 * // ...
14 * generates: {
15 * 'path/to/file.ts': {
16 * preset: 'modules',
17 * plugins: ['typescript-resolvers'],
18 * presetConfig: {
19 * baseTypesPath: 'types.ts'
20 * },
21 * },
22 * },
23 * };
24 * export default config;
25 * ```
26 */
27 baseTypesPath: string;
28 /**
29 * @name importBaseTypesFrom
30 * @type string
31 * @description Overrides the package import for the base types. Use this if you are within a monorepo, and you wish
32 * to import the base types directly from a different package, and not from a relative path.
33 *
34 */
35 importBaseTypesFrom?: string;
36 /**
37 * @name cwd
38 * @type string
39 * @description Optional, override the `cwd` of the execution. We are using `cwd` to figure out the imports between files. Use this if your execution path is not your project root directory.
40 * @default process.cwd()
41 *
42 * @example
43 * ```ts filename="codegen.ts" {10}
44 * import type { CodegenConfig } from '@graphql-codegen/cli';
45 *
46 * const config: CodegenConfig = {
47 * // ...
48 * generates: {
49 * 'path/to/file.ts': {
50 * preset: 'modules',
51 * plugins: ['typescript-resolvers'],
52 * presetConfig: {
53 * baseTypesPath: 'types.ts',
54 * cwd: '/some/path'
55 * },
56 * },
57 * },
58 * };
59 * export default config;
60 * ```
61 */
62 cwd?: string;
63 /**
64 * @name importTypesNamespace
65 * @type string
66 * @description Optional, override the name of the import namespace used to import from the `baseTypesPath` file.
67 * @default Types
68 *
69 * @example
70 * ```ts filename="codegen.ts" {10}
71 * import type { CodegenConfig } from '@graphql-codegen/cli';
72 *
73 * const config: CodegenConfig = {
74 * // ...
75 * generates: {
76 * 'path/to/file.ts': {
77 * preset: 'modules',
78 * plugins: ['typescript-resolvers'],
79 * presetConfig: {
80 * baseTypesPath: 'types.ts',
81 * importTypesNamespace: 'core'
82 * },
83 * },
84 * },
85 * };
86 * export default config;
87 * ```
88 */
89 importTypesNamespace?: string;
90 /**
91 * @name filename
92 * @type string
93 * @description Required, sets the file name for the generated files.
94 *
95 */
96 filename: string;
97 /**
98 * @name encapsulateModuleTypes
99 * @type string
100 * @default namespace
101 * @description Configure how to encapsulate the module types, to avoid confusion.
102 *
103 * `namespace` (default): will wrap all types in a TypeScript namespace, using the module name.
104 * `prefix`: will prefix all types from a specific module with the module name.
105 * `none`: will skip encapsulation, and generate type as-is.
106 *
107 */
108 encapsulateModuleTypes: 'prefix' | 'namespace' | 'none';
109 /**
110 * @name requireRootResolvers
111 * @type boolean
112 * @default false
113 * @description Generate resolvers of root types (Query, Mutation and Subscription) as non-optional.
114 *
115 * @example
116 * ```yml
117 * generates:
118 * src/:
119 * preset: modules
120 * presetConfig:
121 * baseTypesPath: types.ts
122 * filename: types.ts
123 * requireRootResolvers: true
124 * plugins:
125 * - typescript-resolvers
126 * ```
127 */
128 requireRootResolvers?: boolean;
129 /**
130 * @name useGraphQLModules
131 * @type boolean
132 * @default true
133 * @description By default, the generated types will generate some code specific to `graphql-modules` library.
134 *
135 * If you are not using GraphQL-Modules, you can disable this feature by setting this to `false`.
136 */
137 useGraphQLModules?: boolean;
138};