How to structure Graphql, Typescript and Express app for scalability

Share on facebook
Share on google
Share on twitter
Share on linkedin

In this post I will share a great structure for structuring your Graphql application, using Typescript and Express.

The structure consists of these folders/layers (from outer to inner):

  • IOC: Inversion of control provides testability and control over the dependencies in the system. For this, I use “Inversify”
  • Schema: The definition of the GraphQL schemas defined as .gql files for making the schema definition language agnostic.
  • Resolvers: The definition of the resolvers. These are split into query and mutation resolvers.
  • Models: The use case models containing business information and being called by resolvers.
  • Connectors: Layer for doing external requests.
  • Interfaces: Interfaces proving type safety in the GraphQL app.

For testing, there is a tests folder containing a folder for unit tests and one for integration tests. I use Jest for running test as this works great with Typescript and contains a rich test framework with easy setup.

The code for a starter template with this structure can be found at my Github here.

Do you want to become an Angular architect? Check out Angular Architect Accelerator.

Related Posts and Comments

Accelerator

How To Become An In-Demand Angular Architect & Accelerate Your Career In 8 Weeks The Angular Architect Accelerator online program’s next cohort will soon be kicked off! Sign up now by email to learn more and secure a seat for the free warmup workshop. Enrollment is currently closed but the next cohort will start soon…  Sign up to get notified about the

Read More »

Walkthrough: Building An Angular App Using Tailwind CSS and Nx

In this video, we will cover a walk-through from scratch covering how to Build and Angular app using Tailwind CSS and Nx including Angular standalone components. 🖌 Tailwind CSS setup and usage⚙️ Nx monorepo configuration🧍‍♂️ Standalone components✅ Building a complete app in less than 2 hours with best practices ⏳ Timestamps:0:00 – Intro1:00 – Tailwind

Read More »