forked from ForumMagnum/ForumMagnum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
87 lines (84 loc) · 2.2 KB
/
codegen.ts
File metadata and controls
87 lines (84 loc) · 2.2 KB
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
import type { CodegenConfig } from '@graphql-codegen/cli';
const outputPath = "tmp/gql-codegen";
const config: CodegenConfig = {
overwrite: true,
schema: "./packages/lesswrong/lib/generated/gqlSchema.gql",
documents: "./packages/lesswrong/**/*.{ts,tsx}",
generates: {
// One object for client-side query return types
[`${outputPath}/`]: {
preset: "client",
plugins: [{ add: { content: '// @ts-nocheck' } }],
config: {
scalars: {
Date: {
input: 'Date',
output: 'string',
},
},
avoidOptionals: {
inputValue: false,
field: true,
object: false,
defaultValue: true,
resolvers: true,
query: true,
mutation: true,
subscription: true,
},
namingConvention: (s: string) => s.replace("Fragment", ""),
enumsAsTypes: true,
extractAllFieldsToTypes: true,
inlineFragmentTypes: 'combine',
},
presetConfig: {
gqlTagName: 'gql',
fragmentMasking: false,
},
},
// One object for everything-else types
[`${outputPath}/graphqlCodegenTypes.d.ts`]: {
plugins: [
{
typescript: {
scalars: {
Date: {
input: 'Date',
output: 'string',
}
}
}
}, {
'typescript-operations': {
scalars: {
Date: {
input: 'Date',
output: 'string',
}
},
avoidOptionals: {
inputValue: false,
field: true,
object: true,
defaultValue: true,
resolvers: true,
query: true,
mutation: true,
subscription: true,
},
}
}
],
config: {
fragmentMasking: false,
inputMaybeValue: 'T | null | undefined',
namingConvention: (s: string) => s.replace("Fragment", ""),
enumsAsTypes: true,
inlineFragmentTypes: 'combine',
noExport: true,
extractAllFieldsToTypes: true,
}
},
},
};
export default config;