This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17c4bda
commit d8cbf10
Showing
1 changed file
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |