-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodegen.ts
76 lines (73 loc) · 2.55 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
import type {CodegenConfig} from '@graphql-codegen/cli';
const config: CodegenConfig = {
overwrite: true,
schema: 'client/app/shared/generated-schema.graphql',
documents: 'client/**/*.ts',
generates: {
'client/app/shared/generated-types.ts': {
// preset: 'near-operation-file',
plugins: [
'typescript',
'typescript-operations',
{
add: {
content: '/* eslint-disable */',
},
},
],
},
},
hooks: {
afterAllFileWrite: ["prettier --ignore-path '' --write"],
},
config: {
// immutableTypes:true, // TODO enable this when we have time
onlyOperationTypes: true, // Simplifies the generated types
preResolveTypes: true, // Simplifies the generated types
namingConvention: 'keep', // Keeps naming as-is
arrayInputCoercion: false,
strictScalars: true,
avoidOptionals: {field: true}, // Avoids optionals on the level of the field
nonOptionalTypename: true, // Forces `__typename` on all selection sets
skipTypeNameForRoot: true, // Don't generate __typename for root types
omitOperationSuffix: true,
scalars: {
CHF: 'string',
Chronos: {
output: 'string',
input: 'string | Date',
},
Color: 'string',
Date: {
output: 'string',
input: 'string | Date',
},
EUR: 'string',
Email: 'string',
Password: 'string',
Token: 'string',
Upload: 'File',
// All IDs
// Ideally we should not use `any` at all, but we want to be able
// to use either a string or an entire subobject.
CommentID: 'string | any',
CountryID: 'string | any',
EventID: 'string | any',
FileID: 'string | any',
ImageID: 'string | any',
LogID: 'string | any',
MessageID: 'string | any',
NewsID: 'string | any',
OrderLineID: 'string | any',
OrderID: 'string | any',
OrganizationID: 'string | any',
ProductID: 'string | any',
ProductTagID: 'string | any',
SessionID: 'string | any',
SubscriptionID: 'string | any',
UserID: 'string | any',
FacilitatorDocumentID: 'string | any',
},
},
};
export default config;