Scaleable GraphQL Architecture

Ben Grunfeld
4 min readJun 2, 2021

Please follow me on Twitter, or come say hi on LinkedIn, and if you enjoy the article, please give it a clap — they lower my cholesterol 😃

Scalable GraphQL Architecture
Scalable GraphQL Architecture

GraphQL has been the new “In Thing” for a couple of years, but bigger companies are just starting to adopt it, and one of the first questions they ask is: how does it scale?

In my humble opinion, the answer is: it scales WAY better than REST.

The second question is often: ok, how do we scale it?

Here is my approach, which is somewhat simplistic, but extremely functional.

The only tools we’re going to use will be Apollo in the form of apollo-server-express, import statements and Template Literals. You should be able to use any of the Apollo Server modules in the same or a very similar way.

Function First vs Feature First

For a GraphQL API, the two main things you need are typeDefs and resolvers.

As the app grows, you can’t have them all in the same file — it simply gets too big, so how best to break them up?

There are two main approaches: function-first and feature-first.

Function-first means that you would have all the typeDefs grouped together in one directory, and you’d have all the resolvers grouped…

--

--

Ben Grunfeld
Ben Grunfeld

Written by Ben Grunfeld

I’m a Front End Engineer who loves React, NextJS, and GraphQL. Looking for a developer in #Israel? Contact me at: https://www.linkedin.com/in/bengrunfeld/