import { Query , Args , Resolver , Mutation } from '@nestjs/graphql' ; import { CoreResponse } from '@/common/dto/coreResponse.dto' ; import { UseGuards } from '@nestjs/common' ; import { JwtAuthGuard } from '@auth/guards/jwt-auth.guard' ; import { IdRequest } from '@common/dto/inputId.dto' ; import { GetGroupedSkillsResponse } from './dto/getGroupedSkills.dto' ; import { GetSkillsRequest , GetSkillsResponse } from './dto/getSkills.dto' ; import { AddSkillRequest } from './dto/addSkill.dto' ; import { UpdateSkillRequest } from './dto/updateSkill.dto' ; import { SkillsService } from './skills.service' ; @ Resolver ( ) export class SkillsResolver { constructor ( private skillsService ) { } @ Query ( ( returns ) => GetSkillsResponse ) async getSkills ( @ Args ( 'input' , { nullable : true } ) input ? ) { const { skills , error } = await this . skillsService . getByType ( input ?. type ) ; if ( ! skills || error ) return { ok : false , error } ; return { ok : true , skills } ; } @ Query ( ( returns ) => GetGroupedSkillsResponse ) async getGroupedSkills ( ) { const { skills , error } = await this . skillsService . getGroupeds ( ) ; if ( ! skills || error ) return { ok : false , error } ; return { ok : true , skills } ; } @ UseGuards ( JwtAuthGuard ) @ Mutation ( ( returns ) => CoreResponse ) async addSkill ( @ Args ( 'input' ) input ) { const { ok , error } = await this . skillsService . add ( input ) ; return { ok , error } ; } @ UseGuards ( JwtAuthGuard ) @ Mutation ( ( returns ) => CoreResponse ) async deleteSkill ( @ Args ( 'input' ) input ) { const { ok , error } = await this . skillsService . delete ( input . id ) ; return { ok , error } ; } @ UseGuards ( JwtAuthGuard ) @ Mutation ( ( returns ) => CoreResponse ) async updateSkill ( @ Args ( 'input' ) input ) { const { ok , error } = await this . skillsService . update ( input ) ; return { ok , error } ; } }