-
Notifications
You must be signed in to change notification settings - Fork 101
/
codegen.mts
120 lines (118 loc) · 3.95 KB
/
codegen.mts
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import { defineConfig } from '@eddeee888/gcg-typescript-resolver-files';
import { type CodegenConfig } from '@graphql-codegen/cli';
import { addTypenameSelectionDocumentTransform } from '@graphql-codegen/client-preset';
const config: CodegenConfig = {
schema: './packages/services/api/src/modules/*/module.graphql.ts',
emitLegacyCommonJSImports: true,
generates: {
// API
'./packages/services/api/src': defineConfig(
{
typeDefsFilePath: false,
mergeSchema: {
path: '../../../../schema.graphql',
config: { includeDirectives: true },
},
resolverGeneration: 'minimal',
resolverMainFileMode: 'modules',
resolverTypesPath: './__generated__/types.ts',
scalarsOverrides: {
DateTime: {
type: { input: 'Date', output: 'Date | string | number' },
},
Date: { type: 'string' },
SafeInt: { type: 'number' },
ID: { type: 'string' },
},
typesPluginsConfig: {
immutableTypes: true,
namingConvention: 'change-case-all#pascalCase', // TODO: This is triggering a warning about type name not working 100% of the time. eddeee888 to fix in Server Preset by using `meta` field.
contextType: 'GraphQLModules.ModuleContext',
enumValues: {
ProjectType: '../shared/entities#ProjectType',
NativeFederationCompatibilityStatus:
'../shared/entities#NativeFederationCompatibilityStatus',
TargetAccessScope: '../modules/auth/providers/target-access#TargetAccessScope',
ProjectAccessScope: '../modules/auth/providers/project-access#ProjectAccessScope',
OrganizationAccessScope:
'../modules/auth/providers/organization-access#OrganizationAccessScope',
SupportTicketPriority: '../shared/entities#SupportTicketPriority',
SupportTicketStatus: '../shared/entities#SupportTicketStatus',
},
resolversNonOptionalTypename: {
interfaceImplementingType: true,
unionMember: true,
excludeTypes: [
'TokenInfoPayload',
'OrganizationByInviteCodePayload',
'JoinOrganizationPayload',
'Schema',
'GraphQLNamedType',
],
},
},
},
{
hooks: {
afterOneFileWrite: ['prettier --write'],
},
},
),
'./packages/web/app/src/gql/': {
documents: ['./packages/web/app/src/(components|lib|pages|server)/**/*.ts(x)?'],
preset: 'client',
config: {
scalars: {
DateTime: 'string',
Date: 'string',
SafeInt: 'number',
JSONSchemaObject: 'json-schema-typed#JSONSchema',
},
},
presetConfig: {
persistedDocuments: true,
},
plugins: [],
documentTransforms: [addTypenameSelectionDocumentTransform],
},
'./packages/web/app/src/gql/schema.ts': {
plugins: ['urql-introspection'],
config: {
useTypeImports: true,
module: 'es2015',
},
},
// CLI
'./packages/libraries/cli/src/gql/': {
documents: ['./packages/libraries/cli/src/(commands|helpers)/**/*.ts'],
preset: 'client',
plugins: [],
config: {
useTypeImports: true,
},
},
// Client
'packages/libraries/core/src/client/__generated__/types.ts': {
documents: ['./packages/libraries/core/src/client/**/*.ts'],
config: {
flattenGeneratedTypes: true,
onlyOperationTypes: true,
},
plugins: ['typescript', 'typescript-operations'],
},
// Integration tests
'./integration-tests/testkit/gql/': {
documents: ['./integration-tests/(testkit|tests)/**/*.ts'],
preset: 'client',
plugins: [],
config: {
scalars: {
DateTime: 'string',
Date: 'string',
SafeInt: 'number',
},
},
},
},
};
module.exports = config;