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

Angular Mastery Book

Angular Mastery Free Ebook From principles to practice. Accelerate your path to Angular mastery by learning the principles of the industry’s best practices and how you can apply them to your own projects. It’s the manual I wish I had when I got started with Angular development 10 years ago that is designed to save

Read More »

Build a Course Platform with SPARTAN Stack

Build a Course Platform with the SPARTAN Stack​ Step by Step Guide giving you a full production ready setup with industry best practices. <p style=”text-align: center;”><b>Press for sound.</b><b></b></p> <h2>Here’s what’s inside…</h2> <p >Section 1</p> <h2>Designing the course portal (Figma)</h2> <p style=”text-align: left;”>We will cover the fundaments of designing a brand new site in Figma including

Read More »

Courses

Develop Real Projects With Industry Best Practices Join our community of expert developers and get the industry level best practices, step-by-step, from real projects. https://www.youtube.com/watch?v=XHOmBV4js_E Hi, I’m Christian Lüdemann I’m a web developer from Denmark and the creator of this blog. You are here to learn how to code like the best companies and learn

Read More »

Debugging Angular apps (with Sentry) and workflow

In this video, we cover the topic of debugging Angular apps and provide an overview of various tools and approaches that can be used. I highlight the use of Sentry as a tool for error logging and performance monitoring. I also cover my scientific approach to fixing hard-to-debug bugs. Do you want to become an

Read More »