-
Notifications
You must be signed in to change notification settings - Fork 3
/
codegen.js
78 lines (73 loc) · 1.73 KB
/
codegen.js
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
const path = require('path');
const onlyFrontend = process.env.CODEGEN_ONLY_FRONTEND;
const onlyTest = process.env.CODEGEN_ONLY_TEST;
const SUPERDAO_UI_TESTS = 'apps/superdao-ui-tests/src';
const SUPERDAO_FRONTEND = 'apps/superdao-frontend/src';
const SUPERDAO_BACKEND = 'apps/superdao-backend/src';
const superdaoFolders = onlyTest
? [SUPERDAO_UI_TESTS]
: onlyFrontend
? [SUPERDAO_FRONTEND]
: [SUPERDAO_FRONTEND, SUPERDAO_UI_TESTS];
const config = {
[SUPERDAO_FRONTEND]: {
documents: path.join(SUPERDAO_FRONTEND, '**/gql/*.graphql'),
preset: 'near-operation-file',
presetConfig: {
extension: '.generated.ts',
baseTypesPath: 'types/types.generated.ts'
},
plugins: {
add: {
content: '// @ts-nocheck'
},
'typescript-operations': {},
'typescript-react-query': {}
},
config: {
skipTypename: true,
avoidOptionals: true,
addInfiniteQuery: true,
exposeQueryKeys: true,
exposeFetcher: true,
isReactHook: false,
fetcher: 'src/client/gqlApi#requestWrapper'
}
},
[SUPERDAO_UI_TESTS]: {
documents: path.join(SUPERDAO_UI_TESTS, '**/gql/*.graphql'),
preset: 'near-operation-file',
presetConfig: {
extension: '.generated.ts',
baseTypesPath: 'types/types.generated.ts'
},
plugins: {
add: {
content: '// @ts-nocheck'
},
'typescript-operations': {},
'typescript-graphql-request': {}
}
}
};
module.exports = {
schema: './apps/superdao-backend/schema.gql',
generates: superdaoFolders.reduce(
(prev, folder) => ({
...prev,
[path.join(folder, 'types/types.generated.ts')]: {
config: {
withHooks: true
},
plugins: {
typescript: {},
add: {
content: '/* eslint-disable no-shadow */'
}
}
},
[folder]: config[folder]
}),
{}
),
};