How do I practice NestJs? — NestJs + GraphQL + TypeORM + MongoDB

Chnirt
Chnirt
Jun 18 · 3 min read
Built with NestJs, GraphQL, TypeORM, MongoDB

1. Requirement

2. Table of contents

3. Practice

Setup

// Setting up a new project is quite simple with the Nest CLI$ npm i -g @nestjs/cli
// or
$ yarn add global @nestjs/cli
// Create new nest project
$ nest new project-name

Run It!

// Development
$ npm run start
// or
$ yarn start
// Watch mode
$ npm run start:dev
// or
$ yarn start:dev

Logger

GraphQL

$ npm i --save @nestjs/graphql apollo-server-express graphql-tools graphql$ yarn add @nestjs/graphql apollo-server-express graphql-tools graphql
$ nest g mo user
$ nest g r user
$ nest g s user
$ touch src/user/user.graphql
Folder structure

Demo query “Hello world”

TypeORM connect MongoDB

$ npm i --save @nestjs/typeorm typeorm mongodb
// OR
$ yarn add @nestjs/typeorm typeorm mongodb

CRUD with object User

$ touch src/user/user.entity.ts
$ touch src/user/user.input.ts
$ npm i uuid

Chnirt

Written by

Chnirt

𝓗𝓪𝓽𝓮 𝓶𝓮 𝓯𝓲𝓻𝓼𝓽, ❤️ 𝓵𝓪𝓽𝓮𝓻

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade