Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
feat: define PlayerResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
YanceyOfficial committed Dec 27, 2019
1 parent 17c4bda commit d8cbf10
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions src/player/player.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
import { Controller } from '@nestjs/common'
import { Args, Query, Resolver, Mutation } from '@nestjs/graphql'
import { ID } from 'type-graphql'
import { PlayerService } from './player.service'
import { PlayerModel } from './models/player.model'
import { BatchDeleteModel } from '../database/models/database.model'
import { CreatePlayerInput } from './dtos/create-player.input'
import { UpdatePlayerInput } from './dtos/update-player.input'

@Controller('player')
export class PlayerResolver {}
@Resolver(() => PlayerModel)
export class PlayerResolver {
constructor(private readonly playerService: PlayerService) {
this.playerService = playerService
}

@Query(() => [PlayerModel])
public async getPlayer() {
return this.playerService.findAll()
}

@Query(() => PlayerModel)
public async getPlayerById(@Args({ name: 'id', type: () => ID }) id: string) {
return this.playerService.findOneById(id)
}

@Mutation(() => PlayerModel)
public async createPlayer(@Args('input') input: CreatePlayerInput) {
return this.playerService.create(input)
}

@Mutation(() => PlayerModel)
public async updatePlayerById(@Args('input') input: UpdatePlayerInput) {
return this.playerService.update(input)
}

@Mutation(() => PlayerModel)
public async deletePlayerById(@Args({ name: 'id', type: () => ID }) id: string) {
return this.playerService.deleteOneById(id)
}

@Mutation(() => BatchDeleteModel)
public async deletePlayer(@Args({ name: 'ids', type: () => [ID] }) ids: string[]) {
return this.playerService.batchDelete(ids)
}
}

0 comments on commit d8cbf10

Please sign in to comment.