Repository navigation
Expand file tree
/
Copy pathcodegen.ts
More file actions
49 lines (46 loc) · 1.48 KB
/
Copy pathcodegen.ts
File metadata and controls
49 lines (46 loc) · 1.48 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
import type { CodegenConfig } from '@graphql-codegen/cli'
import { readdirSync } from 'node:fs'
// explicit file list instead of a glob: codegen's glob handling trips over
// this repo's size/pattern and falls back to parsing the raw pattern
const sourceFiles: string[] = []
;(function walk(dir: string) {
for (const entry of readdirSync(`src/${dir}`, { withFileTypes: true })) {
const rel = dir ? `${dir}/${entry.name}` : entry.name
if (entry.isDirectory()) {
if (rel === 'gql') continue
walk(rel)
} else if (/\.(ts|tsx)$/.test(entry.name)) {
sourceFiles.push(`src/${rel}`)
}
}
})('')
const config: CodegenConfig = {
schema: 'graphql/schema.graphql',
documents: sourceFiles,
config: {
scalars: {
UUID: { input: 'string', output: 'string' },
Datetime: { input: 'string', output: 'string' },
Date: { input: 'string', output: 'string' },
BigInt: { input: 'number', output: 'number' },
BigFloat: { input: 'number', output: 'number' },
Cursor: { input: 'string', output: 'string' },
JSON: { input: 'unknown', output: 'unknown' },
GeoJSON: { input: 'unknown', output: 'unknown' },
JwtToken: { input: 'string', output: 'string' },
},
},
generates: {
'src/gql/': {
preset: 'client',
presetConfig: {
documentMode: 'documentNode',
gqlTagName: 'graphql',
fragmentMasking: false,
},
plugins: [],
},
},
ignoreNoDocuments: true,
}
export default config