Skip to content

Instantly share code, notes, and snippets.

@chnirt
Last active June 18, 2019 07:51
Show Gist options
  • Save chnirt/eef3484e5bcc5e86e4bb04a0d1ce1d1a to your computer and use it in GitHub Desktop.
Save chnirt/eef3484e5bcc5e86e4bb04a0d1ce1d1a to your computer and use it in GitHub Desktop.
NestJs
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