/
codegen.ts
359 lines (357 loc) · 15 KB
/
codegen.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
import { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
hooks: { afterAllFileWrite: ['prettier --write'] },
emitLegacyCommonJSImports: false,
generates: {
'./dev-test/test-schema/resolvers-types.ts': {
schema: './dev-test/test-schema/schema-text.js',
plugins: ['typescript', 'typescript-resolvers'],
},
'./dev-test/test-schema/flow-types.flow.js': {
schema: './dev-test/test-schema/schema.json',
plugins: ['flow', 'flow-resolvers'],
},
'./dev-test/test-schema/resolvers-root.ts': {
schema: './dev-test/test-schema/schema-with-root.graphql',
plugins: ['typescript', 'typescript-resolvers'],
},
'./dev-test/test-schema/resolvers-federation.ts': {
schema: './dev-test/test-schema/schema-federation.graphql',
config: { federation: true },
plugins: ['typescript', 'typescript-resolvers'],
},
'./dev-test/test-schema/resolvers-stitching.ts': {
schema: './dev-test/test-schema/schema-text.js',
plugins: ['typescript', { 'typescript-resolvers': { noSchemaStitching: false } }],
},
'./dev-test/test-schema/typings.ts': {
schema: './dev-test/test-schema/schema.json',
plugins: ['typescript', 'typescript-resolvers'],
},
'./dev-test/test-schema/typings.avoidOptionals.ts': {
schema: './dev-test/test-schema/schema.json',
config: { avoidOptionals: true },
plugins: ['typescript'],
},
'./dev-test/test-schema/typings.wrapped.ts': {
schema: './dev-test/test-schema/schema.json',
plugins: [
{ add: { content: 'declare namespace GraphQL {' } },
{ add: { placement: 'append', content: '}' } },
'typescript',
'typescript-operations',
],
},
'./dev-test/test-schema/env.types.ts': { schema: process.env.SCHEMA_PATH, plugins: ['typescript'] },
'./dev-test/test-schema/typings.immutableTypes.ts': {
schema: './dev-test/test-schema/schema.json',
config: { imutableTypes: true },
plugins: ['typescript'],
},
'./dev-test/test-schema/typings.enum.ts': {
schema: './dev-test/test-schema/schema-object.js',
plugins: ['typescript'],
},
'./dev-test/githunt/graphql-declared-modules.d.ts': {
schema: './dev-test/githunt/schema.json',
documents: ['./dev-test/githunt/**/*.graphql'],
plugins: ['typescript-graphql-files-modules'],
},
'./dev-test/githunt/typed-document-nodes.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typed-document-node'],
},
'./dev-test/githunt/flow.flow.js': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['flow', 'flow-operations'],
},
'./dev-test/githunt/types.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.preResolveTypes.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { preResolveTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.onlyEnums.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { onlyEnums: true },
plugins: ['typescript'],
},
'./dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { preResolveTypes: true, onlyOperationTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.flatten.preResolveTypes.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { preResolveTypes: true, flattenGeneratedTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.enumsAsTypes.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { enumsAsTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.d.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { enumsAsTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.avoidOptionals.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { avoidOptionals: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.immutableTypes.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { immutableTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/githunt/types.reactApollo.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
},
'./dev-test/githunt/types.reactApollo.v2.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { reactApolloVersion: 2 },
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
},
'./dev-test/githunt/types.reactApollo.customSuffix.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { operationResultSuffix: 'MyOperation' },
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
},
'./dev-test/githunt/types.reactApollo.preResolveTypes.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { preResolveTypes: true },
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
},
'./dev-test/githunt/types.reactApollo.hooks.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
},
'./dev-test/githunt/types.react-query.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-react-query'],
config: { addInfiniteQuery: true },
},
'./dev-test/githunt/types.rtk-query.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: [
{ add: { content: 'module.hot?.accept();' } },
'typescript',
'typescript-operations',
{
'typescript-rtk-query': {
importBaseApiFrom: '../../packages/plugins/typescript/rtk-query/tests/baseApi',
exportHooks: true,
overrideExisting: 'module.hot?.status() === "apply"',
},
},
],
},
'./dev-test/githunt/types.apolloAngular.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-apollo-angular'],
},
'./dev-test/githunt/types.apolloAngular.sdk.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
config: { sdkClass: true },
plugins: ['typescript', 'typescript-operations', 'typescript-apollo-angular'],
},
'./dev-test/githunt/types.stencilApollo.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-stencil-apollo'],
},
'./dev-test/githunt/types.urql.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: [
'typescript',
'typescript-operations',
'typescript-urql',
'urql-introspection',
'typescript-urql-graphcache',
],
},
'./dev-test/githunt': {
schema: './dev-test/githunt/schema.json',
documents: [
'./dev-test/githunt/**/*.graphql',
'./dev-test/githunt-invalid/**/*.graphql',
'!./dev-test/githunt-invalid/**/*.graphql',
],
preset: 'near-operation-file',
presetConfig: { extension: '.stencil-component.tsx', folder: '__generated__', baseTypesPath: 'types.d.ts' },
plugins: ['typescript-operations', 'typescript-stencil-apollo'],
config: { componentType: 'class', globalNamespace: true },
},
'./dev-test/githunt/types.vueApollo.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-vue-apollo'],
},
'./dev-test/githunt/types.vueApolloSmartOps.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-vue-apollo-smart-ops'],
},
'./dev-test/githunt/jit-sdk.ts': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-jit-sdk'],
},
'./dev-test/star-wars/types.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars/types.preResolveTypes.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
config: { preResolveTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars/types.OnlyEnums.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
config: { onlyEnums: true },
plugins: ['typescript'],
},
'./dev-test/star-wars/types.preResolveTypes.onlyOperationTypes.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
config: { preResolveTypes: true, onlyOperationTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/test-schema/types.preResolveTypes.ts': {
schema: './dev-test/test-schema/schema.graphql',
documents: ['query test { testArr1 testArr2 testArr3 }'],
config: { preResolveTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts': {
schema: './dev-test/test-schema/schema.graphql',
documents: ['query test { testArr1 testArr2 testArr3 }'],
config: { preResolveTypes: true, onlyOperationTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars/types.d.ts': {
schema: './dev-test/star-wars/schema.json',
config: { enumsAsTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
preset: 'near-operation-file',
presetConfig: { extension: '.tsx', folder: '__generated__', baseTypesPath: 'types.d.ts' },
plugins: ['typescript-operations', 'typescript-react-apollo'],
},
'./dev-test/modules/': {
schema: './dev-test/modules/*/types/*.graphql',
preset: 'graphql-modules',
presetConfig: { baseTypesPath: 'types.ts', filename: 'generated.ts' },
plugins: ['typescript', 'typescript-resolvers'],
},
'./dev-test/star-wars/types.globallyAvailable.d.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
config: { enumsAsTypes: true, noExport: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars/types.avoidOptionals.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
config: { avoidOptionals: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars/types.immutableTypes.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
config: { immutableTypes: true },
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars/types.skipSchema.ts': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
plugins: ['typescript', 'typescript-operations'],
},
'./dev-test/star-wars/types.refetchFn.tsx': {
schema: './dev-test/star-wars/schema.json',
documents: './dev-test/star-wars/**/*.graphql',
plugins: ['typescript', 'typescript-react-apollo'],
config: { withRefetchFn: true },
},
'./dev-test/test-message/types.tsx': {
schema: './dev-test/test-message/schema.graphql',
documents: './dev-test/test-message/documents.ts',
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
config: {
documentMode: 'external',
importDocumentNodeExternallyFrom: './documents.ts',
reactApolloVersion: 3,
gqlImport: 'graphql-tag',
hooksImportFrom: '@apollo/react-hooks',
withMutationFn: false,
},
},
'./dev-test/gql-tag-operations/gql': {
schema: './dev-test/gql-tag-operations/schema.graphql',
documents: './dev-test/gql-tag-operations/src/**/*.ts',
preset: 'gql-tag-operations-preset',
plugins: [],
},
'./dev-test/gql-tag-operations/graphql': {
schema: './dev-test/gql-tag-operations/schema.graphql',
documents: './dev-test/gql-tag-operations/src/**/*.ts',
preset: 'client',
plugins: [],
},
'./dev-test/gql-tag-operations-urql/gql': {
schema: './dev-test/gql-tag-operations-urql/schema.graphql',
documents: './dev-test/gql-tag-operations-urql/src/**/*.ts',
preset: 'gql-tag-operations-preset',
presetConfig: { augmentedModuleName: '@urql/core' },
plugins: [],
},
'./dev-test/gql-tag-operations-masking/gql': {
schema: './dev-test/gql-tag-operations-masking/schema.graphql',
documents: './dev-test/gql-tag-operations-masking/src/**/*.tsx',
preset: 'gql-tag-operations-preset',
presetConfig: { fragmentMasking: true },
plugins: [],
},
'./dev-test/gql-tag-operations-masking-star-wars/gql': {
schema: './dev-test/gql-tag-operations-masking-star-wars/schema.json',
documents: './dev-test/gql-tag-operations-masking-star-wars/src/**/*.tsx',
preset: 'gql-tag-operations-preset',
presetConfig: { fragmentMasking: true },
plugins: [],
},
},
};
export default config;