You Just Found The Best Node + Typescript + MongoDB GraphQL API Starter Kit

Photo by Kira auf der Heide on Unsplash


I’ve been working with GraphQL and Typescript for about 3 years now and so far I’m loving it. Those two technologies are a delight to work with, but they can become hard to implement.


The goal of this article is to demonstrate how to orchestrate all those technologies together but is not an in-depth tutorial on them. I will assume that you already have knowledge of GraphQL, Typescript, and MongoDB!

Overview of the kit

A clean folder structure

The folder structure as been heavily inspired by this awesome article following the SOLID principle of separation of concerns. If you’ve never read it before, this is a gold mine: please stop here and come back afterward!

The starter kit folder structure

Define your types only once ✌️

One of the biggest issues when using GrapthQL with Typescript and MongoDB is that you quickly find yourself with three type definitions. This is fine on a small project but it quickly becomes very hard to maintain and even small changes can be painful to do.

This example is fine on a small project but doesn’t scale really well
Only one declaration needed! 🤘

Easy and robust testing strategy

Testing your API is a crucial step to ship good quality features with peace of mind. Mixing the apollo-server-testing package, Jest, and MongoDB-memory-server integration testing of your API has never been easier and powerful than that.

The outputof the createTodo mutation in the Jest snapshot



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anthony Riera

Anthony Riera


Software developer — Trying to write more about tech — Currently working on