Learn how to use the benefits of single-table design with your GraphQL API

AppSync is a fully managed service from AWS that lets you build and deploy scalable and secure GraphQL APIs in the cloud. DynamoDB is a NoSQL fully managed and scalable database. Both being serverless services, they are very often used together.

If you are interested in DynamoDB, you have also probably already heard about single-table design. However, that way of designing databases is often considered to be unhelpful with GraphQL.

In this blog post, I will share some ideas on how we can still use single-table design and its benefits with GraphQL, and show some techniques that I use with…

In this post, I will teach you how you can handle many-to-many relations with AWS AppSync, how to avoid denormalization and still avoid the n+1 problem.

TL;DR; Use a Pipeline resolver to first fetch the relations followed by a BatchGetItem operation to retrieve all related items in one single query.

Find the full solution on GitHub

One of the most common problems developers face when designing DynamoDB databases is many-to-many relationships. Usually, the recommended way is to denormalize your data. You duplicate all the fields required by your access pattern in the relation Item so that they are returned along…

CloudFormation is an AWS service that allows you to maintain Infrastructure as Code (IaC). Whether you are using it natively (with JSON or YML) or through a third-party service such as the Serverless Framework, AWS CDK or SAM, it is a great way to make your infrastructure reproducible across various stages. It also makes the deployment process easily automatable through CI/CD pipelines. In other words, it makes managing your infrastructure less prone to human errors.

DynamoDB is a fully managed NoSQL database that delivers single-digit millisecond performance at any scale. In order to keep up with its promises, there are a couple of constraints and good practices that you need to follow. One of them is to keep your items as small as possible. This is true not only for performance but also for cost. With DynamoDB, you pay per amount of data that you read or write as well as for storage. Reducing your data size is important if you want to reduce your monthly bill.

On top of that, DynamoDB also comes with…

One of the great benefits of GraphQL is typing! Define your schema, and GraphQL enforces the input/output “shape” of your endpoints data.

If you are using Lambda as your AppSync resolvers with the node.js runtime, you might be using TypeScript, too. If you do, you might also be defining TS types that correspond to your schema. Doing this manually can be tedious, is prone to error, and is basically doing the same job twice! 🙁 Wouldn’t it be great if you could import your GraphQL types into your code automatically?

In this article, I’ll show you how to generate TypeScript…

AppSync HTTP resolver with DynamoDB cache layer

Updated on 2020–12–26: After posting this, I realized that it could be improved this, even more, by using DynamoDB TTL. I updated this article accordingly.

While I was working on a GraphQL API, I needed a couple of resolvers hitting remote HTTP endpoints. This is rather straightforward with AppSync HTTP data sources. However, I didn't want it hitting the remote APIs at every single request. There were several reasons for that:

  • Latency: Due to several factors, like the location of the remote endpoint, it could add a noticeable overhead and add extra time to the request execution.
  • Throttling: I did…

If you are not familiar with AppSync or the plugin yet, we suggest you to read the following posts first:

Part 1: Introduction: GraphQL endpoints with API Gateway + AWS Lambda
Part 2: AppSync Backend: AWS Managed GraphQL Service
Part 3: AppSync Frontend: AWS Managed GraphQL Service
Part 4: Serverless AppSync Plugin: New Features (this blog)


AWS AppSync is a fully managed serverless GraphQL service for real-time data queries, synchronization, communications, and offline programming features. It is great for building scalable data-driven mobile, web or enterprise applications quickly, and without the hassle of managing complex infrastructures.

Serverless AppSync plugin allows…

Benoît Bouré

Twitter @Benoit_Boure — Need help? Hire me for a one-on-one session http://hiretheauthor.com/bboure

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