1 | import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
|
2 | /**
|
3 | * @description This plugin generates React Apollo components and HOC with TypeScript typings.
|
4 | *
|
5 | * It extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration.
|
6 | */
|
7 | export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfig {
|
8 | /**
|
9 | * @description Customize the output by enabling/disabling the generated Component (deprecated since Apollo-Client v3). For more details: https://apollographql.com/docs/react/api/react/components
|
10 | * @default false
|
11 | *
|
12 | * @exampleMarkdown
|
13 | * ```ts filename="codegen.ts"
|
14 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
15 | *
|
16 | * const config: CodegenConfig = {
|
17 | * // ...
|
18 | * generates: {
|
19 | * 'path/to/file.ts': {
|
20 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
21 | * config: {
|
22 | * withComponent: true
|
23 | * },
|
24 | * },
|
25 | * },
|
26 | * };
|
27 | * export default config;
|
28 | * ```
|
29 | */
|
30 | withComponent?: boolean;
|
31 | /**
|
32 | * @description Customize the output by enabling/disabling the HOC (deprecated since Apollo-Client v3). For more details: https://apollographql.com/docs/react/api/react/hoc
|
33 | * @default false
|
34 | *
|
35 | * @exampleMarkdown
|
36 | * ```ts filename="codegen.ts"
|
37 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
38 | *
|
39 | * const config: CodegenConfig = {
|
40 | * // ...
|
41 | * generates: {
|
42 | * 'path/to/file.ts': {
|
43 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
44 | * config: {
|
45 | * withHOC: true
|
46 | * },
|
47 | * },
|
48 | * },
|
49 | * };
|
50 | * export default config;
|
51 | * ```
|
52 | */
|
53 | withHOC?: boolean;
|
54 | /**
|
55 | * @description Customized the output by enabling/disabling the generated React Hooks. For more details: https://apollographql.com/docs/react/api/react/hooks
|
56 | * @default true
|
57 | *
|
58 | * @exampleMarkdown
|
59 | * ```ts filename="codegen.ts"
|
60 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
61 | *
|
62 | * const config: CodegenConfig = {
|
63 | * // ...
|
64 | * generates: {
|
65 | * 'path/to/file.ts': {
|
66 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
67 | * config: {
|
68 | * withHooks: true
|
69 | * },
|
70 | * },
|
71 | * },
|
72 | * };
|
73 | * export default config;
|
74 | * ```
|
75 | */
|
76 | withHooks?: boolean;
|
77 | /**
|
78 | * @description Customized the output by enabling/disabling the generated mutation function signature.
|
79 | * @default true
|
80 | *
|
81 | * @exampleMarkdown
|
82 | * ```ts filename="codegen.ts"
|
83 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
84 | *
|
85 | * const config: CodegenConfig = {
|
86 | * // ...
|
87 | * generates: {
|
88 | * 'path/to/file.ts': {
|
89 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
90 | * config: {
|
91 | * withMutationFn: true
|
92 | * },
|
93 | * },
|
94 | * },
|
95 | * };
|
96 | * export default config;
|
97 | * ```
|
98 | */
|
99 | withMutationFn?: boolean;
|
100 | /**
|
101 | * @description Enable generating a function to be used with refetchQueries
|
102 | * @default false
|
103 | *
|
104 | * @exampleMarkdown
|
105 | * ```ts filename="codegen.ts"
|
106 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
107 | *
|
108 | * const config: CodegenConfig = {
|
109 | * // ...
|
110 | * generates: {
|
111 | * 'path/to/file.ts': {
|
112 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
113 | * config: {
|
114 | * withRefetchFn: false
|
115 | * },
|
116 | * },
|
117 | * },
|
118 | * };
|
119 | * export default config;
|
120 | * ```
|
121 | */
|
122 | withRefetchFn?: boolean;
|
123 | /**
|
124 | * @description Customize the package where apollo-react common lib is loaded from.
|
125 | * @default "@apollo/react-common"
|
126 | */
|
127 | apolloReactCommonImportFrom?: string;
|
128 | /**
|
129 | * @description Customize the package where apollo-react component lib is loaded from.
|
130 | * @default "@apollo/react-components"
|
131 | */
|
132 | apolloReactComponentsImportFrom?: string;
|
133 | /**
|
134 | * @description Customize the package where apollo-react HOC lib is loaded from.
|
135 | * @default "@apollo/react-hoc"
|
136 | */
|
137 | apolloReactHocImportFrom?: string;
|
138 | /**
|
139 | * @description Customize the package where apollo-react hooks lib is loaded from.
|
140 | * @default "@apollo/react-hooks"
|
141 | */
|
142 | apolloReactHooksImportFrom?: string;
|
143 | /**
|
144 | * @description You can specify a suffix that gets attached to the name of the generated component.
|
145 | * @default Component
|
146 | */
|
147 | componentSuffix?: string;
|
148 | /**
|
149 | * @description Sets the version of react-apollo.
|
150 | * If you are using the old (deprecated) package of `react-apollo`, please set this configuration to `2`.
|
151 | * If you are using Apollo-Client v3, please set this to `3`.
|
152 | * @default 3
|
153 | *
|
154 | * @exampleMarkdown
|
155 | * ```ts filename="codegen.ts"
|
156 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
157 | *
|
158 | * const config: CodegenConfig = {
|
159 | * // ...
|
160 | * generates: {
|
161 | * 'path/to/file.ts': {
|
162 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
163 | * config: {
|
164 | * reactApolloVersion: 2
|
165 | * },
|
166 | * },
|
167 | * },
|
168 | * };
|
169 | * export default config;
|
170 | * ```
|
171 | */
|
172 | reactApolloVersion?: 2 | 3;
|
173 | /**
|
174 | * @description Customized the output by enabling/disabling the generated result type.
|
175 | * @default true
|
176 | *
|
177 | * @exampleMarkdown
|
178 | * ```ts filename="codegen.ts"
|
179 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
180 | *
|
181 | * const config: CodegenConfig = {
|
182 | * // ...
|
183 | * generates: {
|
184 | * 'path/to/file.ts': {
|
185 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
186 | * config: {
|
187 | * withResultType: true
|
188 | * },
|
189 | * },
|
190 | * },
|
191 | * };
|
192 | * export default config;
|
193 | * ```
|
194 | */
|
195 | withResultType?: boolean;
|
196 | /**
|
197 | * @description Customized the output by enabling/disabling the generated mutation option type.
|
198 | * @default true
|
199 | *
|
200 | * @exampleMarkdown
|
201 | * ```ts filename="codegen.ts"
|
202 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
203 | *
|
204 | * const config: CodegenConfig = {
|
205 | * // ...
|
206 | * generates: {
|
207 | * 'path/to/file.ts': {
|
208 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
209 | * config: {
|
210 | * withMutationOptionsType: true
|
211 | * },
|
212 | * },
|
213 | * },
|
214 | * };
|
215 | * export default config;
|
216 | * ```
|
217 | */
|
218 | withMutationOptionsType?: boolean;
|
219 | /**
|
220 | * @description Whether or not to include wrappers for Apollo's useFragment hook.
|
221 | * @default false
|
222 | *
|
223 | * @exampleMarkdown
|
224 | * ```ts filename="codegen.ts"
|
225 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
226 | *
|
227 | * const config: CodegenConfig = {
|
228 | * // ...
|
229 | * generates: {
|
230 | * 'path/to/file.ts': {
|
231 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
232 | * config: {
|
233 | * withFragmentHooks: true
|
234 | * },
|
235 | * },
|
236 | * },
|
237 | * };
|
238 | * export default config;
|
239 | * ```
|
240 | */
|
241 | withFragmentHooks?: boolean;
|
242 | /**
|
243 | * @description Allows you to enable/disable the generation of docblocks in generated code.
|
244 | * Some IDE's (like VSCode) add extra inline information with docblocks, you can disable this feature if your preferred IDE does not.
|
245 | * @default true
|
246 | *
|
247 | * @exampleMarkdown
|
248 | * ```ts filename="codegen.ts"
|
249 | * import type { CodegenConfig } from '@graphql-codegen/cli';
|
250 | *
|
251 | * const config: CodegenConfig = {
|
252 | * // ...
|
253 | * generates: {
|
254 | * 'path/to/file.ts': {
|
255 | * plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
|
256 | * config: {
|
257 | * addDocBlocks: true
|
258 | * },
|
259 | * },
|
260 | * },
|
261 | * };
|
262 | * export default config;
|
263 | * ```
|
264 | */
|
265 | addDocBlocks?: boolean;
|
266 | /**
|
267 | * @description Configure default mutation and query hook options.
|
268 | */
|
269 | defaultBaseOptions?: ReactApolloPluginConfigDefaultBaseOptions;
|
270 | hooksSuffix?: string;
|
271 | }
|
272 | export interface ReactApolloPluginConfigDefaultBaseOptions {
|
273 | awaitRefetchQueries?: boolean;
|
274 | errorPolicy?: string;
|
275 | fetchPolicy?: string;
|
276 | ignoreResults?: boolean;
|
277 | notifyOnNetworkStatusChange?: boolean;
|
278 | returnPartialData?: boolean;
|
279 | ssr?: boolean;
|
280 | [key: string]: any;
|
281 | }
|