2024-06-07 11:27:04 +00:00
import { defineConfig } from '@eddeee888/gcg-typescript-resolver-files' ;
2023-07-25 07:12:08 +00:00
import { type CodegenConfig } from '@graphql-codegen/cli' ;
2023-10-26 10:08:40 +00:00
import { addTypenameSelectionDocumentTransform } from '@graphql-codegen/client-preset' ;
2023-02-21 12:24:41 +00:00
2023-07-25 07:12:08 +00:00
const config : CodegenConfig = {
2023-02-21 12:24:41 +00:00
schema : './packages/services/api/src/modules/*/module.graphql.ts' ,
emitLegacyCommonJSImports : true ,
generates : {
// API
2024-06-07 11:27:04 +00:00
'./packages/services/api/src' : defineConfig (
{
typeDefsFilePath : false ,
2024-07-02 07:55:55 +00:00
mergeSchema : {
path : '../../../../schema.graphql' ,
config : { includeDirectives : true } ,
} ,
2024-06-07 11:27:04 +00:00
resolverGeneration : 'minimal' ,
resolverMainFileMode : 'modules' ,
resolverTypesPath : './__generated__/types.next.ts' ,
2024-10-01 11:01:34 +00:00
blacklistedModules : [ 'collection' , 'schema' ] ,
2024-06-07 11:27:04 +00:00
scalarsOverrides : {
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' ,
} ,
2024-06-13 13:17:56 +00:00
resolversNonOptionalTypename : {
interfaceImplementingType : true ,
unionMember : true ,
2024-10-01 11:01:34 +00:00
excludeTypes : [
'TokenInfoPayload' ,
'OrganizationByInviteCodePayload' ,
'JoinOrganizationPayload' ,
] ,
2024-06-13 13:17:56 +00:00
} ,
2024-06-07 11:27:04 +00:00
} ,
} ,
{
hooks : {
afterOneFileWrite : [ 'prettier --write' ] ,
} ,
} ,
) ,
2023-02-21 12:24:41 +00:00
'./packages/services/api/src/modules' : {
preset : 'graphql-modules' ,
2024-05-28 10:49:29 +00:00
plugins : [ 'typescript' , 'typescript-resolvers' ] ,
2023-02-21 12:24:41 +00:00
presetConfig : {
baseTypesPath : '../__generated__/types.ts' ,
filename : '__generated__/types.ts' ,
encapsulateModuleTypes : 'namespace' ,
} ,
config : {
immutableTypes : true ,
contextType : 'GraphQLModules.ModuleContext' ,
enumValues : {
ProjectType : '../shared/entities#ProjectType' ,
2023-12-14 13:10:50 +00:00
NativeFederationCompatibilityStatus :
'../shared/entities#NativeFederationCompatibilityStatus' ,
2023-02-21 12:24:41 +00:00
TargetAccessScope : '../modules/auth/providers/target-access#TargetAccessScope' ,
ProjectAccessScope : '../modules/auth/providers/project-access#ProjectAccessScope' ,
OrganizationAccessScope :
'../modules/auth/providers/organization-access#OrganizationAccessScope' ,
2023-09-06 11:35:08 +00:00
SupportTicketPriority : '../shared/entities#SupportTicketPriority' ,
SupportTicketStatus : '../shared/entities#SupportTicketStatus' ,
2023-02-21 12:24:41 +00:00
} ,
scalars : {
DateTime : 'string' ,
2024-04-05 10:51:54 +00:00
Date : 'string' ,
2023-02-21 12:24:41 +00:00
SafeInt : 'number' ,
2023-06-20 12:01:46 +00:00
ID : 'string' ,
2023-02-21 12:24:41 +00:00
} ,
mappers : {
2024-05-24 11:34:46 +00:00
SchemaChange : '../modules/schema/module.graphql.mappers#SchemaChangeMapper' ,
2023-11-16 12:35:51 +00:00
SchemaChangeApproval :
2024-05-24 11:34:46 +00:00
'../modules/schema/module.graphql.mappers#SchemaChangeApprovalMapper' ,
2023-02-21 12:24:41 +00:00
SchemaChangeConnection :
2024-05-24 11:34:46 +00:00
'../modules/schema/module.graphql.mappers#SchemaChangeConnectionMapper' ,
2023-02-21 12:24:41 +00:00
SchemaErrorConnection :
2024-05-24 11:34:46 +00:00
'../modules/schema/module.graphql.mappers#SchemaErrorConnectionMapper' ,
2023-05-09 08:07:17 +00:00
SchemaWarningConnection :
2024-05-24 11:34:46 +00:00
'../modules/schema/module.graphql.mappers#SchemaWarningConnectionMapper' ,
2023-02-21 12:24:41 +00:00
OrganizationConnection :
2024-05-28 10:49:29 +00:00
'../modules/organization/module.graphql.mappers#OrganizationConnectionMapper' ,
UserConnection : '../modules/auth/module.graphql.mappers#UserConnectionMapper' ,
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' ,
2023-09-28 12:52:52 +00:00
OperationStatsValuesConnection :
2024-05-28 10:49:29 +00:00
'../modules/operations/module.graphql.mappers#OperationStatsValuesConnectionMapper' ,
2023-09-28 12:52:52 +00:00
ClientStatsValuesConnection :
2024-05-28 10:49:29 +00:00
'../modules/operations/module.graphql.mappers#ClientStatsValuesConnectionMapper' ,
2023-09-27 13:41:22 +00:00
SchemaCoordinateStats :
2024-05-28 10:49:29 +00:00
'../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' ,
2023-02-21 12:24:41 +00:00
SchemaVersionConnection :
2024-05-28 10:49:29 +00:00
'../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' ,
AlertChannel : '../modules/alerts/module.graphql.mappers#AlertChannelMapper' ,
AlertSlackChannel : '../modules/alerts/module.graphql.mappers#AlertSlackChannelMapper' ,
AlertWebhookChannel : '../modules/alerts/module.graphql.mappers#AlertWebhookChannelMapper' ,
2024-07-09 15:14:53 +00:00
TeamsWebhookChannel : '../modules/alerts/module.graphql.mappers#TeamsWebhookChannelMapper' ,
2024-05-28 10:49:29 +00:00
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' ,
2023-02-21 12:24:41 +00:00
AdminOrganizationStats :
2024-05-28 10:49:29 +00:00
'../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' ,
2023-02-21 12:24:41 +00:00
OrganizationGetStarted :
2024-05-28 10:49:29 +00:00
'../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' ,
2023-02-21 12:24:41 +00:00
OrganizationInvitation :
2024-05-28 10:49:29 +00:00
'../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' ,
2023-06-12 14:56:27 +00:00
DocumentCollectionOperation :
2024-05-28 10:49:29 +00:00
'../modules/collection/module.graphql.mappers#DocumentCollectionOperationMapper' ,
DocumentCollectionConnection :
'../modules/collection/module.graphql.mappers#DocumentCollectionConnectionMapper' ,
2023-06-12 14:56:27 +00:00
DocumentCollectionOperationsConnection :
2024-05-28 10:49:29 +00:00
'../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' ,
2024-02-26 10:36:48 +00:00
BreakingChangeMetadataTarget :
2024-05-28 10:49:29 +00:00
'../modules/schema/module.graphql.mappers#BreakingChangeMetadataTargetMapper' ,
2024-07-19 09:13:51 +00:00
AppDeployment : '../modules/app-deployments/module.graphql.mappers#AppDeploymentMapper' ,
AppDeploymentStatus :
'../modules/app-deployments/module.graphql.mappers#AppDeploymentStatusMapper' ,
2023-02-21 12:24:41 +00:00
} ,
} ,
} ,
'./packages/web/app/src/gql/' : {
documents : [
2024-05-17 12:30:10 +00:00
'./packages/web/app/src/(components|lib|pages)/**/*.ts(x)?' ,
'!./packages/web/app/src/server/**/*.ts' ,
2023-02-21 12:24:41 +00:00
] ,
2023-02-24 14:39:44 +00:00
preset : 'client' ,
2023-05-09 08:07:17 +00:00
config : {
scalars : {
DateTime : 'string' ,
2024-04-05 10:51:54 +00:00
Date : 'string' ,
2023-05-09 08:07:17 +00:00
SafeInt : 'number' ,
JSONSchemaObject : 'json-schema-typed#JSONSchema' ,
} ,
} ,
2023-07-25 07:12:08 +00:00
presetConfig : {
persistedDocuments : true ,
} ,
2023-02-21 12:24:41 +00:00
plugins : [ ] ,
2023-10-26 10:08:40 +00:00
documentTransforms : [ addTypenameSelectionDocumentTransform ] ,
2023-02-21 12:24:41 +00:00
} ,
2023-10-04 18:45:04 +00:00
'./packages/web/app/src/gql/schema.ts' : {
plugins : [ 'urql-introspection' ] ,
config : {
useTypeImports : true ,
module : 'es2015' ,
} ,
} ,
2023-02-21 12:24:41 +00:00
// CLI
2023-07-04 15:19:45 +00:00
'./packages/libraries/cli/src/gql/' : {
2024-02-26 10:36:48 +00:00
documents : [ './packages/libraries/cli/src/(commands|helpers)/**/*.ts' ] ,
2023-07-04 15:19:45 +00:00
preset : 'client' ,
plugins : [ ] ,
2023-02-21 12:24:41 +00:00
config : {
2023-07-04 15:19:45 +00:00
useTypeImports : true ,
2023-02-21 12:24:41 +00:00
} ,
} ,
// Client
2024-04-23 15:51:43 +00:00
'packages/libraries/core/src/client/__generated__/types.ts' : {
documents : [ './packages/libraries/core/src/client/**/*.ts' ] ,
2023-02-21 12:24:41 +00:00
config : {
flattenGeneratedTypes : true ,
onlyOperationTypes : true ,
} ,
plugins : [ 'typescript' , 'typescript-operations' ] ,
} ,
// Integration tests
'./integration-tests/testkit/gql/' : {
2023-06-12 14:56:27 +00:00
documents : [ './integration-tests/(testkit|tests)/**/*.ts' ] ,
2023-02-24 14:39:44 +00:00
preset : 'client' ,
2023-02-21 12:24:41 +00:00
plugins : [ ] ,
2024-05-22 07:55:27 +00:00
config : {
scalars : {
DateTime : 'string' ,
Date : 'string' ,
SafeInt : 'number' ,
} ,
} ,
2023-02-21 12:24:41 +00:00
} ,
} ,
} ;
module . exports = config ;