-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcodegen.ts
More file actions
28 lines (25 loc) · 1003 Bytes
/
codegen.ts
File metadata and controls
28 lines (25 loc) · 1003 Bytes
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
import { loadEnvFile } from 'node:process';
import type { CodegenConfig } from '@graphql-codegen/cli';
loadEnvFile(process.env.LOCAL ? '.env.development.local' : '.env');
const config: CodegenConfig = {
schema: process.env.VITE_GQL_URL,
documents: 'src/**/*.{ts,tsx}',
generates: {
'./src/gql-types/schema.graphql': {
plugins: ['schema-ast'], // converts the json response from introspection query to a .graphql file
},
'./src/gql-types/': {
preset: 'client',
presetConfig: {
// fragmentMasking hides fields outside of the component that defines the fragment
// - turning off is easier to work with, and it doesn't matter because we're not using any fragments yet
fragmentMasking: false,
},
config: {
// generates string unions instead of enums
enumsAsTypes: true,
},
},
},
};
export default config;