forked from graphql-hive/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.mts
267 lines (265 loc) · 13 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
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.next.ts',
blacklistedModules: [
'alerts',
'auth',
'billing',
'collection',
'feedback',
'lab',
'oidc-integrations',
'operations',
'organization',
'policy',
'project',
'schema',
'target',
],
scalarsOverrides: {
DateTime: { type: 'string' },
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'],
},
},
},
{
hooks: {
afterOneFileWrite: ['prettier --write'],
},
},
),
'./packages/services/api/src/modules': {
preset: 'graphql-modules',
plugins: ['typescript', 'typescript-resolvers'],
presetConfig: {
baseTypesPath: '../__generated__/types.ts',
filename: '__generated__/types.ts',
encapsulateModuleTypes: 'namespace',
},
config: {
immutableTypes: true,
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',
},
scalars: {
DateTime: 'string',
Date: 'string',
SafeInt: 'number',
ID: 'string',
},
mappers: {
SchemaChange: '../modules/schema/module.graphql.mappers#SchemaChangeMapper',
SchemaChangeApproval:
'../modules/schema/module.graphql.mappers#SchemaChangeApprovalMapper',
SchemaChangeConnection:
'../modules/schema/module.graphql.mappers#SchemaChangeConnectionMapper',
SchemaErrorConnection:
'../modules/schema/module.graphql.mappers#SchemaErrorConnectionMapper',
SchemaWarningConnection:
'../modules/schema/module.graphql.mappers#SchemaWarningConnectionMapper',
OrganizationConnection:
'../modules/organization/module.graphql.mappers#OrganizationConnectionMapper',
UserConnection: '../modules/auth/module.graphql.mappers#UserConnectionMapper',
ActivityConnection: '../modules/activity/module.graphql.mappers#ActivityConnectionMapper',
MemberConnection: '../modules/auth/module.graphql.mappers#MemberConnectionMapper',
ProjectConnection: '../modules/project/module.graphql.mappers#ProjectConnectionMapper',
TargetConnection: '../modules/target/module.graphql.mappers#TargetConnectionMapper',
SchemaConnection: '../modules/schema/module.graphql.mappers#SchemaConnectionMapper',
TokenConnection: '../modules/token/module.graphql.mappers#TokenConnectionMapper',
OperationStatsValuesConnection:
'../modules/operations/module.graphql.mappers#OperationStatsValuesConnectionMapper',
ClientStatsValuesConnection:
'../modules/operations/module.graphql.mappers#ClientStatsValuesConnectionMapper',
SchemaCoordinateStats:
'../modules/operations/module.graphql.mappers#SchemaCoordinateStatsMapper',
ClientStats: '../modules/operations/module.graphql.mappers#ClientStatsMapper',
OperationsStats: '../modules/operations/module.graphql.mappers#OperationsStatsMapper',
DurationValues: '../modules/operations/module.graphql.mappers#DurationValuesMapper',
SchemaVersionConnection:
'../modules/schema/module.graphql.mappers#SchemaVersionConnectionMapper',
SchemaVersion: '../modules/schema/module.graphql.mappers#SchemaVersionMapper',
Schema: '../modules/schema/module.graphql.mappers#SchemaMapper',
SingleSchema: '../modules/schema/module.graphql.mappers#SingleSchemaMapper',
CompositeSchema: '../modules/schema/module.graphql.mappers#CompositeSchemaMapper',
Organization: '../modules/organization/module.graphql.mappers#OrganizationMapper',
Project: '../modules/project/module.graphql.mappers#ProjectMapper',
Target: '../modules/target/module.graphql.mappers#TargetMapper',
Member: '../modules/auth/module.graphql.mappers#MemberMapper',
MemberRole: '../modules/organization/module.graphql.mappers#MemberRoleMapper',
Token: '../modules/token/module.graphql.mappers#TokenMapper',
TokenInfo: '../modules/token/module.graphql.mappers#TokenInfoMapper',
Activity: '../modules/activity/module.graphql.mappers#ActivityMapper',
AlertChannel: '../modules/alerts/module.graphql.mappers#AlertChannelMapper',
AlertSlackChannel: '../modules/alerts/module.graphql.mappers#AlertSlackChannelMapper',
AlertWebhookChannel: '../modules/alerts/module.graphql.mappers#AlertWebhookChannelMapper',
TeamsWebhookChannel: '../modules/alerts/module.graphql.mappers#TeamsWebhookChannelMapper',
Alert: '../modules/alerts/module.graphql.mappers#AlertMapper',
AdminQuery: '../modules/admin/module.graphql.mappers#AdminQueryMapper',
AdminStats: '../modules/admin/module.graphql.mappers#AdminStatsMapper',
AdminGeneralStats: '../modules/admin/module.graphql.mappers#AdminGeneralStatsMapper',
AdminOrganizationStats:
'../modules/admin/module.graphql.mappers#AdminOrganizationStatsMapper',
BillingPaymentMethod:
'../modules/billing/module.graphql.mappers#BillingPaymentMethodMapper',
BillingDetails: '../modules/billing/module.graphql.mappers#BillingDetailsMapper',
BillingInvoice: '../modules/billing/module.graphql.mappers#BillingInvoiceMapper',
OrganizationGetStarted:
'../modules/organization/module.graphql.mappers#OrganizationGetStartedMapper',
SchemaExplorer: '../modules/schema/module.graphql.mappers#SchemaExplorerMapper',
UnusedSchemaExplorer:
'../modules/schema/module.graphql.mappers#UnusedSchemaExplorerMapper',
DeprecatedSchemaExplorer:
'../modules/schema/module.graphql.mappers#DeprecatedSchemaExplorerMapper',
GraphQLObjectType: '../modules/schema/module.graphql.mappers#GraphQLObjectTypeMapper',
GraphQLInterfaceType:
'../modules/schema/module.graphql.mappers#GraphQLInterfaceTypeMapper',
GraphQLUnionType: '../modules/schema/module.graphql.mappers#GraphQLUnionTypeMapper',
GraphQLEnumType: '../modules/schema/module.graphql.mappers#GraphQLEnumTypeMapper',
GraphQLInputObjectType:
'../modules/schema/module.graphql.mappers#GraphQLInputObjectTypeMapper',
GraphQLScalarType: '../modules/schema/module.graphql.mappers#GraphQLScalarTypeMapper',
GraphQLUnionTypeMember:
'../modules/schema/module.graphql.mappers#GraphQLUnionTypeMemberMapper',
GraphQLEnumValue: '../modules/schema/module.graphql.mappers#GraphQLEnumValueMapper',
GraphQLField: '../modules/schema/module.graphql.mappers#GraphQLFieldMapper',
GraphQLInputField: '../modules/schema/module.graphql.mappers#GraphQLInputFieldMapper',
GraphQLArgument: '../modules/schema/module.graphql.mappers#GraphQLArgumentMapper',
OrganizationInvitation:
'../modules/organization/module.graphql.mappers#OrganizationInvitationMapper',
OIDCIntegration:
'../modules/oidc-integrations/module.graphql.mappers#OIDCIntegrationMapper',
User: '../modules/auth/module.graphql.mappers#UserMapper',
SchemaPolicy: '../modules/policy/module.graphql.mappers#SchemaPolicyMapper',
SchemaPolicyRule: '../modules/policy/module.graphql.mappers#SchemaPolicyRuleMapper',
SchemaCoordinateUsage:
'../modules/schema/module.graphql.mappers#SchemaCoordinateUsageMapper',
DocumentCollection:
'../modules/collection/module.graphql.mappers#DocumentCollectionMapper',
DocumentCollectionOperation:
'../modules/collection/module.graphql.mappers#DocumentCollectionOperationMapper',
DocumentCollectionConnection:
'../modules/collection/module.graphql.mappers#DocumentCollectionConnectionMapper',
DocumentCollectionOperationsConnection:
'../modules/collection/module.graphql.mappers#DocumentCollectionOperationsConnectionMapper',
FailedSchemaCheck: '../modules/schema/module.graphql.mappers#FailedSchemaCheckMapper',
SuccessfulSchemaCheck:
'../modules/schema/module.graphql.mappers#SuccessfulSchemaCheckMapper',
SchemaPolicyWarningConnection:
'../modules/schema/module.graphql.mappers#SchemaPolicyWarningConnectionMapper',
Contract: '../modules/schema/module.graphql.mappers#ContractMapper',
ContractConnection: '../modules/schema/module.graphql.mappers#ContractConnectionMapper',
ContractCheck: '../modules/schema/module.graphql.mappers#ContractCheckMapper',
ContractVersion: '../modules/schema/module.graphql.mappers#ContractVersionMapper',
BreakingChangeMetadataTarget:
'../modules/schema/module.graphql.mappers#BreakingChangeMetadataTargetMapper',
},
},
},
'./packages/web/app/src/gql/': {
documents: [
'./packages/web/app/src/(components|lib|pages)/**/*.ts(x)?',
'./packages/web/app/src/graphql',
'!./packages/web/app/src/server/**/*.ts',
],
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;