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' ,
2024-10-30 11:32:13 +00:00
resolverTypesPath : './__generated__/types.ts' ,
2024-06-07 11:27:04 +00:00
scalarsOverrides : {
2024-10-14 08:28:10 +00:00
DateTime : {
type : { input : 'Date' , output : 'Date | string | number' } ,
} ,
2024-06-07 11:27:04 +00:00
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-10-14 08:28:10 +00:00
'Schema' ,
'GraphQLNamedType' ,
2024-10-01 11:01:34 +00:00
] ,
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/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 ;