-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
50 lines (47 loc) · 1.28 KB
/
codegen.ts
File metadata and controls
50 lines (47 loc) · 1.28 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
/**
* GraphQL codegen + shared enum generation
* Run: npm run codegen
*/
import type { CodegenConfig } from '@graphql-codegen/cli';
import { execSync } from 'child_process';
const config: CodegenConfig = {
overwrite: true,
schema: 'http://localhost:3000/admin-api',
hooks: {
beforeAllFileWrite: () => {
console.log('🔄 Generating shared enums...');
try {
execSync('ts-node scripts/generate-shared-enums.ts', { stdio: 'inherit' });
} catch (error) {
console.error('⚠️ Failed to generate shared enums:', error);
}
},
},
config: {
strict: true,
maybeValue: 'T',
scalars: {
ID: 'string | number',
Money: 'number',
DateTime: 'string',
JSON: 'Record<string, unknown>',
Upload: 'File',
},
namingConvention: {
enumValues: 'keep',
},
},
generates: {
'src/gql/generated.ts': {
plugins: ['typescript'],
},
'dashboard/gql/': {
preset: 'client',
documents: 'dashboard/**/*.{ts,tsx}',
presetConfig: {
fragmentMasking: false,
},
},
},
};
export default config;