Code Monkey home page Code Monkey logo

medium-graphql-nestjs's Introduction

[Nestjs + Mongodb + Graphql]

enter image description here

[Nestjs + Graphql] codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged fullstack application built with Nestjs + Graphql including CRUD operations, authentication, routing, pagination, and more.

Screenshots

create user

JWT login

add article to favorite

create article

get all articles and comments with pagination

add comment to article

How it works

A medium like backend server using nestjs with Graphql and mongodb as presitance layer.

Packages

  1. @nestjs/config: Configuration module with .env support for nestjs
  2. @nestjs/jwt: Support JWT authentication for nestjs
  3. @nestjs/mongoose: support mongoose (Mongodb ORM) for nestjs
  4. @nestjs/passport: Nodejs authentication module that supports multiple strategies
  5. @nestjs/graphql: Add Graphql support for nestjs
  6. graphql-subscriptions; Add subscription with websockets for graphql
  7. dataloader: support graphql batch loading
  8. graphql-upload: add file upload to graphql

Why Dataloader ?

Dataloader is used to solve the popular N+1 problem, by batching requests and making one rquest to the database to fetch multiple objects, instead of N queries, this will optimize the graphql queries significantly, more about the problem can be found here

Graphql Upload

graphql file upload was done by graphql-upload node package

Graphql Schema

full graphql schema can be found at schema.gql

Graphql Subscription

subscription is done using graphql-subscriptions, 2 events can be subscribed:

1. when article created

2. when a new comment added

Getting started

  1. add .env file with fallowing values:
    SERVER_PORT=3000
    MONGODB_URI=mongodb://localhost:27017/medium
    DEBUG=true
    SECRET_KEY=secret-key UPLOAD_PATH=./static

  2. yarn install

  3. yarn start

  4. Head to http://localhost:3000/graphql to check graphql playground.

medium-graphql-nestjs's People

Contributors

ramzitannous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

medium-graphql-nestjs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.