-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.ts
84 lines (80 loc) · 2.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
import type { CodegenConfig } from '@graphql-codegen/cli';
const excludedFiles = ['!**/__generated__/**/*', '!**/node_modules/**/*'];
const nearOperationPresetCommon = {
preset: 'near-operation-file',
presetConfig: {
baseTypesPath: 'graphql/__generated__/types.ts',
extension: '.gql.ts',
folder: '__generated__',
},
plugins: ['typescript-operations', 'typescript-react-apollo'],
config: {
avoidOptionals: {
field: true,
inputValue: true,
object: false,
defaultValue: true,
},
experimentalFragmentVariables: true,
inlineFragmentType: 'combine',
namingConvention: 'keep',
omitOperationSuffix: true,
},
};
const config: CodegenConfig = {
overwrite: true,
config: {
enumAsConst: true,
namingConvention: {
enumValues: 'keep',
},
strictScalars: true,
scalars: {
Base64Image: 'string',
BigInt: 'string',
Date: 'string',
Decimal: 'string',
Fingerprint: 'string',
FourDigitYear: 'number',
Hour: 'number',
ISO8601Date: 'string',
ISO8601DateTime: 'string',
JSON: 'Record<string, any>',
JsonChunk: 'Record<string, any>',
join__FieldSet: 'any',
link__Import: 'any',
},
useImplementingTypes: true,
},
schema: 'app/graphql/schema.graphql',
generates: {
'frontend/': {
...nearOperationPresetCommon,
preset: 'near-operation-file',
hooks: {
afterOneFileWrite: ['yarn prettier --write'],
},
documents: ['frontend/**/*.{ts,tsx,js,jsx,graphql}', ...excludedFiles],
},
'frontend/graphql/__generated__/apolloClientOptions.ts': {
plugins: ['fragment-matcher'],
config: {
useExplicitTyping: true,
},
hooks: {
afterOneFileWrite: ['yarn prettier --write'],
},
},
'frontend/graphql/__generated__/apolloClientHelpers.ts': {
plugins: ['typescript-apollo-client-helpers'],
config: {
useTypeImports: true,
},
hooks: {
afterOneFileWrite: ['yarn prettier --write'],
},
},
'frontend/graphql/__generated__/types.ts': { plugins: ['typescript'] },
},
};
export default config;