Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

egghead.io

Use GraphQL Data Loaders to Prevent Scaling Issues by Batching & Caching Database Requests

via egghead.io

Overview

Most developers would raise an eyebrow if they saw database queries being done in a for-loop, but GraphQL provides just enough abstraction that it isn't always intuitive exactly how many times each resolver fires at scale, nor is it obvious how to batch operations efficiently and still return the correct results to the correct consumer
You'll learn how to use the GraphQL Data Loader pattern to improve the performance of your application, and solve scaling issues before they become a problem.
To do this, we'll first implement our own naive version of the pattern to understand why the API is shaped how it is. Then we will switch over to the official DataLoader package and explore the benefits further.
Follow Along
With just a couple of clicks, you'll be able to set up a Gitpod to follow along and optimize a GraphQL API as you work through the course. Navigate to the GitHub Repository and get started!
Check out the Gitpod here!
Skills you'll Gain
Implement a cache layer to optimize your requests
Batch requests so your Database isn't overloaded
Build a performant GraphQL API

Syllabus

  • Detect Scaling Issues When Loading Data In a GraphQL API
  • Cache Database Requests Across GraphQL Resolvers
  • Batch Database Requests with a GraphQL API
  • Refactor the Data Loader into a Reusable Class
  • Create a New Cache on Every GraphQL Request Using Apollo Context
  • Install the DataLoader Package
  • Fetching an Item by ID with a GraphQL DataLoader
  • Fetching Many Items by Key with GraphQL DataLoaders
  • Count the Items in a Collection By Reusing a Data Loader
  • Count the Items in a Collection with a Custom Data Loader

Taught by

Jacob Paris

Reviews

4.5 rating at egghead.io based on 9 ratings

Start your review of Use GraphQL Data Loaders to Prevent Scaling Issues by Batching & Caching Database Requests

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.