MichalLytek / typegraphql-prisma

Prisma generator to emit TypeGraphQL types and CRUD resolvers from your Prisma schema

Home Page:https://prisma.typegraphql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing function property on applyModelsEnhanceMap#fields

robertt opened this issue · comments

commented

In the docs, this example is used as a way of overriding the _all in applyModelsEhnanceMap:

applyModelsEnhanceMap({
  User: {
    fields: {
      // all fields are protected against unauthorized access
      _all: [Authorized()],
      // this field has additional decorators to apply
      password: [
        Extensions({ logMessage: "Danger zone", logLevel: LogLevel.WARN }),
      ],
      // this field is public, no `@Authorized` decorator returned
      id: allDecorators => [],
    },
  },
});

In the generated code, the type definition of the fields property is:

type FieldsConfig<TTypeKeys extends string = string> = Partial<Record<TTypeKeys | "_all", PropertyDecorator[]>>;

Not allowing a function to be passed. Could this be fixed/is there an alternative way of achieving this? Happy to take a stab.

Please update type-graphql version to the latest one.

image