import { ParseUUIDPipe } from '@nestjs/common' ; import { Args , Mutation , Resolver , Query } from '@nestjs/graphql' ; import { NewGroupInput , Permission , UpdateGroupInput , UpdateGroupPermissionInput , } from '../../schema/graphql.schema' ; import Group from '../entity/group.entity' ; import { GroupService } from '../service/group.service' ; import { Permissions } from '../permissions.decorator' ; import { PermissionsType } from '../constants/authorization.constants' ; @ Resolver ( 'Group' ) export class GroupResolver { constructor ( private groupService ) { } @ Permissions ( PermissionsType . ViewGroups ) @ Query ( ) getGroups ( ) { return this . groupService . getAllGroups ( ) ; } @ Permissions ( PermissionsType . ViewGroups ) @ Query ( ) getGroup ( @ Args ( 'id' , ParseUUIDPipe ) id ) { return this . groupService . getGroupById ( id ) ; } @ Permissions ( PermissionsType . CreateGroups ) @ Mutation ( ) async createGroup ( @ Args ( 'input' ) groupInput ) { return this . groupService . createGroup ( groupInput ) ; } @ Permissions ( PermissionsType . EditGroups ) @ Mutation ( ) async updateGroup ( @ Args ( 'id' , ParseUUIDPipe ) id , @ Args ( 'input' ) groupInput ) { return this . groupService . updateGroup ( id , groupInput ) ; } @ Permissions ( PermissionsType . EditGroups ) @ Mutation ( ) async updateGroupPermissions ( @ Args ( 'id' , ParseUUIDPipe ) id , @ Args ( 'input' ) groupInput ) { return this . groupService . updateGroupPermissions ( id , groupInput ) ; } @ Permissions ( PermissionsType . DeleteGroups ) @ Mutation ( ) async deleteGroup ( @ Args ( 'id' , ParseUUIDPipe ) id ) { return this . groupService . deleteGroup ( id ) ; } @ Permissions ( PermissionsType . ViewGroups ) @ Query ( ) async getGroupPermissions ( @ Args ( 'id' , ParseUUIDPipe ) id ) { return this . groupService . getGroupPermissions ( id ) ; } }