-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathcodegen.ts
More file actions
41 lines (37 loc) · 1.11 KB
/
codegen.ts
File metadata and controls
41 lines (37 loc) · 1.11 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
import type { CodegenConfig } from '@graphql-codegen/cli';
import dotenv from 'dotenv';
dotenv.config();
if (!process.env.GITHUB_TOKEN) {
// biome-ignore lint/suspicious/noConsole: CLI script output
console.warn(
'\x1b[33m⚠ GITHUB_TOKEN is not set. Skipping GraphQL codegen.\n' +
' To generate updated types, create a .env file with a valid GitHub PAT.\n' +
' See .env.template for details.\x1b[0m',
);
process.exit(0);
}
const config: CodegenConfig = {
overwrite: true,
schema: {
'https://api.github.com/graphql': {
headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
},
},
},
documents: ['src/renderer/utils/api/**/*.graphql'],
generates: {
'src/renderer/utils/api/graphql/generated/graphql.ts': {
plugins: ['typescript', 'typescript-operations', 'typed-document-node'],
config: {
onlyOperationTypes: true,
documentMode: 'string',
useTypeImports: true,
enumsAsTypes: true,
skipTypename: true,
fragmentMasking: false, // Disables masking
},
},
},
};
export default config;