diff --git a/experiments/index.ts b/experiments/index.ts index d5952346..d0ac6690 100644 --- a/experiments/index.ts +++ b/experiments/index.ts @@ -42,7 +42,7 @@ import { ModelsEnhanceMap, applyModelsEnhanceMap, ModelConfig, - applyOutputTypeEnhanceMap, + applyOutputTypesEnhanceMap, OutputTypeConfig, } from "./prisma/generated/type-graphql"; import { PrismaClient } from "./prisma/generated/client"; @@ -71,8 +71,7 @@ const aggregateClientConfig: OutputTypeConfig<"AggregateClient"> = { avg: [Extensions({ complexity: 10 })], }, }; - -applyOutputTypeEnhanceMap({ +applyOutputTypesEnhanceMap({ AggregateClient: aggregateClientConfig, ClientAvgAggregate: { fields: { diff --git a/experiments/prisma/generated/type-graphql/enhance.ts b/experiments/prisma/generated/type-graphql/enhance.ts index 8bf4836b..b9b7b33e 100644 --- a/experiments/prisma/generated/type-graphql/enhance.ts +++ b/experiments/prisma/generated/type-graphql/enhance.ts @@ -239,16 +239,16 @@ export type OutputTypeConfig = { fields?: OutputTypeFieldsConfig; }; -export type OutputTypeEnhanceMap = { +export type OutputTypesEnhanceMap = { [TModel in OutputTypesNames]?: OutputTypeConfig; }; -export function applyOutputTypeEnhanceMap( - outputTypeEnhanceMap: OutputTypeEnhanceMap, +export function applyOutputTypesEnhanceMap( + outputTypesEnhanceMap: OutputTypesEnhanceMap, ) { - for (const outputTypeEnhanceMapKey of Object.keys(outputTypeEnhanceMap)) { - const outputTypeName = outputTypeEnhanceMapKey as keyof typeof outputTypeEnhanceMap; - const typeConfig = outputTypeEnhanceMap[outputTypeName]!; + for (const outputTypeEnhanceMapKey of Object.keys(outputTypesEnhanceMap)) { + const outputTypeName = outputTypeEnhanceMapKey as keyof typeof outputTypesEnhanceMap; + const typeConfig = outputTypesEnhanceMap[outputTypeName]!; const typeClass = outputTypes[outputTypeName]; const typeTarget = typeClass.prototype; applyTypeClassEnhanceConfig(typeConfig, typeClass, typeTarget); diff --git a/src/generator/enhance.ts b/src/generator/enhance.ts index f13d3de2..b77d181b 100644 --- a/src/generator/enhance.ts +++ b/src/generator/enhance.ts @@ -211,16 +211,16 @@ export function generateEnhanceMap( fields?: OutputTypeFieldsConfig; }; - export type OutputTypeEnhanceMap = { + export type OutputTypesEnhanceMap = { [TModel in OutputTypesNames]?: OutputTypeConfig; }; - export function applyOutputTypeEnhanceMap( - outputTypeEnhanceMap: OutputTypeEnhanceMap, + export function applyOutputTypesEnhanceMap( + outputTypesEnhanceMap: OutputTypesEnhanceMap, ) { - for (const outputTypeEnhanceMapKey of Object.keys(outputTypeEnhanceMap)) { - const outputTypeName = outputTypeEnhanceMapKey as keyof typeof outputTypeEnhanceMap; - const typeConfig = outputTypeEnhanceMap[outputTypeName]!; + for (const outputTypeEnhanceMapKey of Object.keys(outputTypesEnhanceMap)) { + const outputTypeName = outputTypeEnhanceMapKey as keyof typeof outputTypesEnhanceMap; + const typeConfig = outputTypesEnhanceMap[outputTypeName]!; const typeClass = outputTypes[outputTypeName]; const typeTarget = typeClass.prototype; applyTypeClassEnhanceConfig(typeConfig, typeClass, typeTarget); diff --git a/tests/regression/__snapshots__/enhance.ts.snap b/tests/regression/__snapshots__/enhance.ts.snap index dad1ee6d..c6820ac5 100644 --- a/tests/regression/__snapshots__/enhance.ts.snap +++ b/tests/regression/__snapshots__/enhance.ts.snap @@ -164,16 +164,16 @@ export type OutputTypeConfig = { fields?: OutputTypeFieldsConfig; }; -export type OutputTypeEnhanceMap = { +export type OutputTypesEnhanceMap = { [TModel in OutputTypesNames]?: OutputTypeConfig; }; -export function applyOutputTypeEnhanceMap( - outputTypeEnhanceMap: OutputTypeEnhanceMap, +export function applyOutputTypesEnhanceMap( + outputTypesEnhanceMap: OutputTypesEnhanceMap, ) { - for (const outputTypeEnhanceMapKey of Object.keys(outputTypeEnhanceMap)) { - const outputTypeName = outputTypeEnhanceMapKey as keyof typeof outputTypeEnhanceMap; - const typeConfig = outputTypeEnhanceMap[outputTypeName]!; + for (const outputTypeEnhanceMapKey of Object.keys(outputTypesEnhanceMap)) { + const outputTypeName = outputTypeEnhanceMapKey as keyof typeof outputTypesEnhanceMap; + const typeConfig = outputTypesEnhanceMap[outputTypeName]!; const typeClass = outputTypes[outputTypeName]; const typeTarget = typeClass.prototype; applyTypeClassEnhanceConfig(typeConfig, typeClass, typeTarget);