Thanks to gitdagray
for initial skeleton for this project: https://github.com/gitdagray/nestjs-course. The graphql implementation was inspired by: https://github.com/vahid-nejad/nestjs-graphql-course.
The initial skeleton provides REST endpoints for doing CRUD operations on users
which is an in memory list of users and their attributes.
- [ x ] Incorporate a GraphQL interface.
- [ x ] Implement a parent child relationship with an in-memory
posts
collection. - [ x ] Implement a dataloader to optimize retrieval of user posts.
- [ x ] Implement a mutation with DTO validations for creating a new user.
- [ x ] Implement a user query to retrieve a single user.
- [ x ] Add additional e2e tests for GraphQL API.
Access the GraphQL Playground at http://localhost:3000/graphql
The GraphQL API can now satisfy the following queries:
# users corresponds to the name given to the "findAll" resolver
{users {id, name, email, role}}
# with posts
{users {id, name, email, role, posts {content}}}
# get a single user
{user(id: 1) { id name email role }}
# create a user, returns the new user with the `id` created on the server
mutation {
createUser(createUserInput: { email: "[email protected]", role: ADMIN, name: "Alice" }) {
name
role
email
id
}
}
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.