---
title: "Shopify’s journey to faster breadth-first GraphQL execution"
description: "Shopify built GraphQL Cardinal, a breadth-first GraphQL execution engine that calls each field resolver once with the full set of objects at that level instead of once per object."
url: "https://swe.quest/articles/shopify-s-journey-to-faster-breadth-first-graphql-execution-83f0f58b8c4dabd1"
canonical: "https://shopify.engineering/faster-breadth-first-graphql-execution"
source: "Shopify Engineering"
published: "2026-03-12"
difficulty: "hard"
kind: "Case study"
reading_minutes: 14
tags: ["graphql","performance","ruby","query-engines"]
---

# Shopify’s journey to faster breadth-first GraphQL execution

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2026-03-12, 14 min read, Case study. Original: [https://shopify.engineering/faster-breadth-first-graphql-execution](https://shopify.engineering/faster-breadth-first-graphql-execution)

## Summary

Shopify built GraphQL Cardinal, a breadth-first GraphQL execution engine that calls each field resolver once with the full set of objects at that level instead of once per object. Depth-first execution, used by graphql-ruby and graphql-js, multiplies per-field overhead from tracing hooks, authorization and dataloader promises by response breadth. Cardinal builds a typed execution tree, runs a bottom-up lookbehind planning pass inspired by Grafast, and executes generation by generation with flat object/result sets in a queue-driven loop rather than recursion. Large list queries ran up to 15x faster with 90% less memory and saved over 4s at P50. The tradeoffs are that errors are inlined and located by a final depth traversal, and that migrating a monolith from one-in/one-out resolvers requires an incremental bridge.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [GraphQL](https://swe.quest/tags/graphql.md) (Backend & APIs)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)

## Prerequisites

- GraphQL resolvers ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))
- dataloader batching
- Ruby performance profiling ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))

## Keywords

GraphQL Cardinal, graphql-ruby, graphql-batch, graphql-js, Grafast, Shopify Admin API

## Related posts

- [How we use GraphQL at Europe's largest fashion e-commerce company](https://swe.quest/articles/how-we-use-graphql-at-europe-s-largest-fashion-e-commerce-company-98c53d6b8b858147.md): Zalando Engineering · 2021-03-03 · Easy · 6 min read · GraphQL, API design, Microservices, E-commerce, Resilience
  Zalando replaced a sprawl of per-page and per-platform Backend-for-Frontend services with a single unified GraphQL API owned via a shared monorepo across 12+ domain teams.
- [Querying Strategies for GraphQL Clients](https://swe.quest/articles/querying-strategies-for-graphql-clients-25fcea5a0897f025.md): Shopify Engineering · 2021-06-15 · Medium · 8 min read · GraphQL, Mobile, Web performance, Frontend
  GraphQL client queries tend to grow slower and harder to roll out as features accumulate, and Shopify's Orders & Fulfillments web and mobile teams work through a progression of strategies against a sub-one-second mobile page load goal.
- [Rate Limiting GraphQL APIs by Calculating Query Complexity](https://swe.quest/articles/rate-limiting-graphql-apis-by-calculating-query-complexity-58ede655d49d3a42.md): Shopify Engineering · 2021-06-22 · Medium · 6 min read · GraphQL, API design, Resilience
  Shopify's GraphQL Admin API rate-limits by calculated query cost instead of request count: clients get 50 points per second up to a 1,000-point bucket, and each query is priced by static analysis before execution.
- [Optimize GraphQL Server with Lookaheads](https://swe.quest/articles/optimize-graphql-server-with-lookaheads-2ec291286b4baa0c.md): Zalando Engineering · 2021-03-17 · Medium · 12 min read · GraphQL, API design, Performance engineering, JavaScript
  Zalando's GraphQL server uses lookaheads on the resolver's info AST (fieldNodes and selection sets) to work out which sub-fields a query requests, then forwards them to backends that support partial responses via a fields parameter.
- [Keeping it 100(x) with real-time data at scale](https://swe.quest/articles/keeping-it-100-x-with-real-time-data-at-scale-3b49e279c5a600f2.md): Figma · 2024-05-17 · Medium · 19 min read · Caching, Real-time systems, Scaling, PostgreSQL, System design
  Figma rebuilt LiveGraph, its real-time GraphQL-like subscription service over Postgres, to scale reads and database update load 100x as the database moved from one instance to vertical and horizontal shards.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
