-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodegen.ts
More file actions
42 lines (39 loc) · 1.13 KB
/
codegen.ts
File metadata and controls
42 lines (39 loc) · 1.13 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
import type { CodegenConfig } from '@graphql-codegen/cli'
const defaultSchemaUrl = 'https://api.sonar.8640p.info/graphql'
const rawSchemaUrl = process.env.SONAR_API_URL ?? defaultSchemaUrl
const schemaUrl = rawSchemaUrl.endsWith('/graphql')
? rawSchemaUrl
: `${rawSchemaUrl.replace(/\/$/, '')}/graphql`
// https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-graphql-request
const config: CodegenConfig = {
overwrite: true,
schema: schemaUrl,
documents: ['src/**/*'],
hooks: {
afterAllFileWrite: ['pnpm biome check --write src/types/sonar.ts --linter-enabled=false'],
},
generates: {
'./src/types/sonar.ts': {
plugins: [
'typescript',
'typescript-operations',
'typescript-graphql-request',
],
config: {
rawRequest: true,
extensionsType: 'unknown',
noGraphQLTag: true,
strictScalars: true,
scalars: {
JSON: 'JSON',
DateTime: 'Date',
_Any: 'unknown',
Any: 'unknown',
},
// documentMode: 'string',
// defaultScalarType: 'unknown',
},
},
},
}
export default config