import { ParseUUIDPipe } from '@nestjs/common' ; import { Args , Mutation , Resolver , Query } from '@nestjs/graphql' ; import { Entity , NewEntityInput , UpdateEntityInput , UpdateEntityPermissionInput , } from '../../schema/graphql.schema' ; import { PermissionsType } from '../constants/authorization.constants' ; import Permission from '../entity/permission.entity' ; import { Permissions } from '../permissions.decorator' ; import { EntityService } from '../service/entity.service' ; @ Resolver ( 'Entity' ) export class EntityResolver { constructor ( private entityService ) { } @ Query ( ) @ Permissions ( PermissionsType . ViewEntities ) getEntities ( ) { return this . entityService . getAllEntities ( ) ; } @ Query ( ) @ Permissions ( PermissionsType . ViewEntities ) getEntity ( @ Args ( 'id' , ParseUUIDPipe ) id ) { return this . entityService . getEntityById ( id ) ; } @ Mutation ( ) @ Permissions ( PermissionsType . CreateEntities ) async createEntity ( @ Args ( 'input' ) entityInput ) { return this . entityService . createEntity ( entityInput ) ; } @ Mutation ( ) @ Permissions ( PermissionsType . EditEntities ) async updateEntity ( @ Args ( 'id' , ParseUUIDPipe ) id , @ Args ( 'input' ) entityInput ) { return this . entityService . updateEntity ( id , entityInput ) ; } @ Mutation ( ) @ Permissions ( PermissionsType . EditEntities ) async updateEntityPermissions ( @ Args ( 'id' , ParseUUIDPipe ) id , @ Args ( 'input' ) entityInput ) { return this . entityService . updateEntityPermissions ( id , entityInput ) ; } @ Query ( ) @ Permissions ( PermissionsType . ViewEntities ) async getEntityPermissions ( @ Args ( 'id' , ParseUUIDPipe ) id ) { return this . entityService . getEntityPermissions ( id ) ; } @ Mutation ( ) @ Permissions ( PermissionsType . DeleteEntities ) async deleteEntity ( @ Args ( 'id' , ParseUUIDPipe ) id ) { return this . entityService . deleteEntity ( id ) ; } }