This package provides a simple way to define and guard GraphQL operations (Query / Mutation)
npm install @egiev/gqlpermimport { GraphqlPermissionModule } from '@egiev/gqlperm';
@Module({
imports: [
GraphqlPermissionModule.forRootAsync({
useFactory: (configService: ConfigService) => ({
domain: configService.get('PROJECT_NAME') || 'user',
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}Use the built-in @Public() decorator to allow open access to specific resolvers:
import { Public } from '@egiev/gqlperm';
@Resolver()
export class AuthResolver {
@Query(() => String)
@Public()
test() {
return 'OK';
}
}-
The module injects AuthGuard and PermissionGuard as global guards.
-
The AuthGuard checks for valid request identity.
-
The PermissionGuard builds a permission string using:
<domain>.<operation>.<method>
- domain – From your config (e.g., "user")
- operation – GraphQL operation type (query / mutation)
- method – Name of the resolver method (e.g., getProfile)
This project is licensed under the MIT