In this tutorial (my first ever! how nervous 😮), I’ll show you how to set up a basic Node.js server exposing a User model stored in a MongoDB database through GraphQL.We’ll also throw some tests and auth tooling on top of that!

  • requirements
  • before all
  • dependencies
  • user model
  • auth service
  • graphql schema
  • graphql resolver
  • testing
  • with resolvers
  • with services
  • app.js
  • playground

The beautiful tools we’ll be using in this tutorial

REQUIREMENTS

  • Have  MongoDB installed and running on your machine
  • Have  Node.js installed (go for version 14 or higher as I use optional chaining which is not supported by v13 and below)
  • Have some knowledge of javascript and node

BEFORE ALL

You’ll find the complete server on  this public repo.

If you want to build it yourself along the way, create a new folder and type yarn init or npm init depending on what package manager you prefer to set up the project.

And speaking of packages, let’s start by installing all the dependencies we’ll need during this tutorial!

#jest #javascript #graphql #nodejs #mongodb

GraphQL | Node.js | MongoDB : set up a basic server with User model and auth
1.60 GEEK