-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.ts
More file actions
71 lines (64 loc) · 1.54 KB
/
Copy pathcodegen.ts
File metadata and controls
71 lines (64 loc) · 1.54 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as addPlugin from '@graphql-codegen/add'
import type { CodegenConfig } from '@graphql-codegen/cli'
import { preset } from '@graphql-codegen/client-preset'
import * as dotenv from 'dotenv'
dotenv.config({
path: './.env.local',
})
const originalBuildGeneratesSection = preset.buildGeneratesSection
preset.buildGeneratesSection = async (...args: Parameters<typeof originalBuildGeneratesSection>) => {
const result = originalBuildGeneratesSection(...args)
if (!Array.isArray(result)) return await result
result.forEach(({ pluginMap, plugins }) => {
if ('fragment-masking' in pluginMap) {
// eslint-disable-next-line no-param-reassign -- modifying existing object
pluginMap.add = addPlugin
plugins.push({ add: { content: '/* eslint-disable */' } })
}
})
return result
}
const config: CodegenConfig = {
overwrite: true,
generates: {
'src/app/src/gql/': {
config: {
scalars: {
DateTime: 'string',
},
namingConvention: {
typeNames: 'keep',
enumValues: 'change-case-all#pascalCase',
},
},
documents: [
'src/app/**/*.tsx',
'src/app/**/*.ts',
'src/**/*.tsx',
'src/**/*.ts',
'!src/app/(payload)/**/*',
'!src/app/src/sea-battle/**/*',
],
preset: 'client',
presetConfig: {
fragmentMasking: { unmaskFunctionName: 'getFragmentData' },
},
schema: [
{
'./src/gql/schema.graphql': {},
},
],
plugins: [
{
add: {
content: '/* eslint-disable */',
},
},
],
hooks: {
afterOneFileWrite: [],
},
},
},
}
export default config