import type { CodegenConfig } from '@graphql-codegen/cli'; import {IGraphQLProjects} from 'graphql-config'; import mercuriusValidation from 'mercurius-validation'; // GraphQL Code Generator configuration // This will generate only the basic output types, enums, and scalars // which are used by the backend and frontend. const config: IGraphQLProjects = { projects: { default: { schema: [ require.resolve('@opengov/ppf-backend-graphql-schema'), mercuriusValidation.graphQLTypeDefs, ], extensions: { codegen: { ignoreNoDocuments: false, // for better experience with the watcher generates: { './src/types/generated.ts': { plugins: ['typescript'], config: { // List all pre-defined enum types here. // NOTE: To avoid this maintenance burden, we could use the module name here: // enumValues: './enums' // But then every enum in the schema must be defined in the enums.ts file. enumValues: { PaymentProcessorFlow: "./enums#PaymentProcessorFlow", ConfigScope: "./enums#ConfigScope", PaymentMethod: "./enums#PaymentMethod", ImplementationTeam: "./enums#ImplementationTeam", PaymentProcessorId: "./enums#PaymentProcessorId", OpenGovTenant: "./enums#OpenGovTenant", PaymentStatus: "./enums#PaymentStatus", }, scalars: { DateTime: "Date | string", Date: "Date | string", }, // Ensures that the generated types have the same name as the // types in the graphql schema. (i.e. 'SEPSMetadata' is NOT converted to 'SepsMetadata') namingConvention: 'keep', }, }, }, hooks: { afterAllFileWrite: [ 'prettier --write' ], }, } satisfies CodegenConfig, }, }, }, }; export default config;