unlight / prisma-nestjs-graphql

Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module
MIT License
540 stars 79 forks source link

[Question] Support for @Extensions? #115

Open ghost opened 2 years ago

ghost commented 2 years ago

Hello, I am wondering if this could be supported.

https://docs.nestjs.com/graphql/extensions

unlight commented 2 years ago

I think it has too dynamic nature.

@Field({ middleware: [checkRoleMiddleware] })
@Extensions({ role: Role.ADMIN })
password: string;

We need to import Role, checkRoleMiddleware...

I would make model as abstract (see https://github.com/unlight/prisma-nestjs-graphql#objecttype), then add own decorators, see https://docs.nestjs.com/graphql/resolvers#generics

asanovr commented 2 years ago

@unlight How I can mark Input classes as abstract? I'm looking for a solution to restrict create/connectOrCreate/delete/disconnect/upsert operations depending on user access and his roles

unlight commented 2 years ago

@asanovr Check https://github.com/unlight/prisma-nestjs-graphql#objecttype