forked from graphql-hive/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codegen.mts
206 lines (204 loc) · 9.83 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
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/modules': {
preset: 'graphql-modules',
plugins: [
{
add: {
content: "import type { StripeTypes } from '@hive/stripe-billing';",
},
},
'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',
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',
SafeInt: 'number',
ID: 'string',
},
mappers: {
SchemaChangeConnection:
'../shared/mappers#SchemaChangeConnection as SchemaChangeConnectionMapper',
SchemaErrorConnection:
'../shared/mappers#SchemaErrorConnection as SchemaErrorConnectionMapper',
SchemaWarningConnection:
'../shared/mappers#SchemaWarningConnection as SchemaWarningConnectionMapper',
OrganizationConnection:
'../shared/mappers#OrganizationConnection as OrganizationConnectionMapper',
UserConnection: '../shared/mappers#UserConnection as UserConnectionMapper',
ActivityConnection: '../shared/mappers#ActivityConnection as ActivityConnectionMapper',
MemberConnection: '../shared/mappers#MemberConnection as MemberConnectionMapper',
ProjectConnection: '../shared/mappers#ProjectConnection as ProjectConnectionMapper',
TargetConnection: '../shared/mappers#TargetConnection as TargetConnectionMapper',
SchemaConnection: '../shared/mappers#SchemaConnection as SchemaConnectionMapper',
TokenConnection: '../shared/mappers#TokenConnection as TokenConnectionMapper',
OperationStatsValuesConnection:
'../shared/mappers#OperationStatsValuesConnection as OperationStatsValuesConnectionMapper',
ClientStatsValuesConnection:
'../shared/mappers#ClientStatsValuesConnection as ClientStatsValuesConnectionMapper',
SchemaCoordinateStats:
'../shared/mappers#SchemaCoordinateStats as SchemaCoordinateStatsMapper',
ClientStats: '../shared/mappers#ClientStats as ClientStatsMapper',
OperationsStats: '../shared/mappers#OperationsStats as OperationsStatsMapper',
DurationValues: '../shared/mappers#DurationValues as DurationValuesMapper',
SchemaComparePayload:
'../shared/mappers#SchemaComparePayload as SchemaComparePayloadMapper',
SchemaCompareResult: '../shared/mappers#SchemaCompareResult as SchemaCompareResultMapper',
SchemaCompareError: '../shared/mappers#SchemaCompareError as SchemaCompareErrorMapper',
SchemaVersionConnection:
'../shared/mappers#SchemaVersionConnection as SchemaVersionConnectionMapper',
SchemaVersion: '../shared/mappers#SchemaVersion as SchemaVersionMapper',
Schema: '../shared/mappers#Schema as SchemaMapper',
SingleSchema: '../shared/mappers#SingleSchema as SingleSchemaMapper',
CompositeSchema: '../shared/mappers#PushedCompositeSchema as PushedCompositeSchemaMapper',
PersistedOperationConnection:
'../shared/mappers#PersistedOperationConnection as PersistedOperationMapper',
Organization: '../shared/entities#Organization as OrganizationMapper',
Project: '../shared/entities#Project as ProjectMapper',
Target: '../shared/entities#Target as TargetMapper',
Member: '../shared/entities#Member as MemberMapper',
Token: '../shared/entities#Token as TokenMapper',
TokenInfo: '../shared/entities#Token as TokenInfoMapper',
Activity: '../shared/entities#ActivityObject as ActivityMapper',
AlertChannel: '../shared/entities#AlertChannel as AlertChannelMapper',
AlertSlackChannel: 'AlertChannelMapper',
AlertWebhookChannel: 'AlertChannelMapper',
Alert: '../shared/entities#Alert as AlertMapper',
AdminQuery: '{}',
AdminStats: '../shared/mappers#AdminStats as AdminStatsMapper',
AdminGeneralStats: '../shared/mappers#AdminStats as AdminGeneralStatsMapper',
AdminOrganizationStats:
'../shared/entities#AdminOrganizationStats as AdminOrganizationStatsMapper',
UsageEstimation: '../shared/mappers#TargetsEstimationFilter',
UsageEstimationScope: '../shared/mappers#TargetsEstimationDateFilter',
BillingPaymentMethod: 'StripeTypes.PaymentMethod.Card',
BillingDetails: 'StripeTypes.PaymentMethod.BillingDetails',
BillingInvoice: 'StripeTypes.Invoice | StripeTypes.UpcomingInvoice',
OrganizationGetStarted:
'../shared/entities#OrganizationGetStarted as OrganizationGetStartedMapper',
SchemaExplorer: '../shared/mappers#SchemaExplorerMapper',
UnusedSchemaExplorer: '../shared/mappers#UnusedSchemaExplorerMapper',
GraphQLObjectType: '../shared/mappers#GraphQLObjectTypeMapper',
GraphQLInterfaceType: '../shared/mappers#GraphQLInterfaceTypeMapper',
GraphQLUnionType: '../shared/mappers#GraphQLUnionTypeMapper',
GraphQLEnumType: '../shared/mappers#GraphQLEnumTypeMapper',
GraphQLInputObjectType: '../shared/mappers#GraphQLInputObjectTypeMapper',
GraphQLScalarType: '../shared/mappers#GraphQLScalarTypeMapper',
GraphQLUnionTypeMember: '../shared/mappers#GraphQLUnionTypeMemberMapper',
GraphQLEnumValue: '../shared/mappers#GraphQLEnumValueMapper',
GraphQLField: '../shared/mappers#GraphQLFieldMapper',
GraphQLInputField: '../shared/mappers#GraphQLInputFieldMapper',
GraphQLArgument: '../shared/mappers#GraphQLArgumentMapper',
OrganizationInvitation:
'../shared/entities#OrganizationInvitation as OrganizationInvitationMapper',
OIDCIntegration: '../shared/entities#OIDCIntegration as OIDCIntegrationMapper',
User: '../shared/entities#User as UserMapper',
SchemaPolicy: '../shared/entities#SchemaPolicy as SchemaPolicyMapper',
SchemaPolicyRule: '../shared/entities#SchemaPolicyAvailableRuleObject',
SchemaCoordinateUsage: '../shared/mappers#SchemaCoordinateUsageTypeMapper',
DocumentCollection: '../shared/entities#DocumentCollection as DocumentCollectionEntity',
DocumentCollectionOperation:
'../shared/entities#DocumentCollectionOperation as DocumentCollectionOperationEntity',
DocumentCollectionConnection: '../shared/entities#PaginatedDocumentCollections',
DocumentCollectionOperationsConnection:
'../shared/entities#PaginatedDocumentCollectionOperations',
FailedSchemaCheck: '../shared/mappers#FailedSchemaCheckMapper',
SuccessfulSchemaCheck: '../shared/mappers#SuccessfulSchemaCheckMapper',
SchemaPolicyWarningConnection: '../shared/mappers#SchemaPolicyWarningConnectionMapper',
},
},
},
// App
'./packages/web/app/src/graphql/index.ts': {
documents: [
'./packages/web/app/src/graphql/*.graphql',
'./packages/web/app/src/(components|lib)/**/*.ts(x)?',
],
plugins: ['typescript', 'typescript-operations', 'typed-document-node'],
config: {
dedupeFragments: true,
scalars: {
DateTime: 'string',
SafeInt: 'number',
JSONSchemaObject: 'json-schema-typed#JSONSchema',
},
},
},
'./packages/web/app/src/gql/': {
documents: [
'./packages/web/app/src/(components|lib)/**/*.ts(x)?',
'./packages/web/app/pages/v2/**/*.ts(x)?',
'./packages/web/app/pages/**/*.ts(x)?',
'./packages/web/app/src/graphql',
'!./packages/web/app/pages/api/github/setup-callback.ts',
],
preset: 'client',
config: {
scalars: {
DateTime: '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/**/*.ts'],
preset: 'client',
plugins: [],
config: {
useTypeImports: true,
},
},
// Client
'packages/libraries/client/src/__generated__/types.ts': {
documents: ['./packages/libraries/client/src/**/*.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: [],
},
},
};
module.exports = config;