-
Notifications
You must be signed in to change notification settings - Fork 19
/
codegen.ts
52 lines (50 loc) · 1.21 KB
/
codegen.ts
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
import 'dotenv/config';
import { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
overwrite: true,
config: {
nonOptionalTypename: true,
dedupeFragments: true,
},
schema: [
{
[process.env.GQL_URL]: {
headers: {
Authorization: `Bearer ${process.env.GQL_ACCESS_TOKEN}`,
},
},
},
],
generates: {
'./src/lib/graphql/__generated__/schema.graphql': {
plugins: ['schema-ast'],
},
'./src/lib/graphql/__generated__/base-types.ts': {
plugins: ['typescript'],
},
'./src/': {
preset: 'near-operation-file',
documents: ['src/**/!(*.generated).{ts,graphql,svelte}'],
presetConfig: {
folder: '__generated__',
extension: '.generated.ts',
gqlTagName: 'gql',
fileName: 'gql',
pruneGeneratedFiles: true,
baseTypesPath: 'lib/graphql/__generated__/base-types.ts',
},
plugins: ['typescript-operations'],
config: {
dedupeFragments: true,
namingConvention: {
enumValues: 'keep',
},
useTypeImports: true,
},
},
},
hooks: {
afterAllFileWrite: ['prettier --write'],
},
};
export default config;