Last active
June 18, 2019 07:51
-
-
Save chnirt/eef3484e5bcc5e86e4bb04a0d1ce1d1a to your computer and use it in GitHub Desktop.
NestJs
This file contains hidden or 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
import { Resolver, Query, Mutation, Args } from '@nestjs/graphql'; | |
import { UserService } from './user.service'; | |
import { User } from './user.entity'; | |
import { UserInput } from './user.input'; | |
@Resolver('User') | |
export class UserResolver { | |
constructor(private readonly userService: UserService) {} | |
@Query(() => String) | |
async hello() { | |
return await 'world'; | |
} | |
@Query(() => [User]) | |
async users() { | |
return this.userService.findAll(); | |
} | |
@Mutation(() => User) | |
async createUser(@Args('input') input: UserInput) { | |
return await this.userService.create(input); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment