-

WG Day:

Menlo Park, California
Back to Schedule

Greg MacWilliam

Shopify's Breadth-First Bet: Rethinking GraphQL Execution

Peahi
Performance

Session description

Pretty much every major GraphQL execution implementation follows the same pattern: depth-first traversal. But the spec doesn’t require this. At Shopify, we challenged that status quo and rewrote GraphQL execution to run breadth-first. Here’s how it works: instead of running a field resolver repeatedly across each object in a list during its depth pass, we execute each field resolver only once per selection with a complete breadth of objects spanning the response. The napkin math is compelling—5 fields resolved across a list of 100 objects running depth-first will produce 500 resolver calls + lazy promises, while running breadth-first will only produce 5. We’ve seen dramatic results with some large list queries shaving many seconds off their end-to-end response times. This talk will cover: * Why depth-first has hidden costs that scale linearly. * How breadth-first inverts the cost model. * Why dataloaders are a hack. * The trade-offs we accepted. * How we're incrementally migrating to breadth execution. If you've ever been concerned that CPU-bound GraphQL performance doesn't scale well, this talk offers a new perspective—and proof that challenging conventions can pay off.


Session speakers

Greg MacWilliam

Shopify, Staff Software Engineer

Greg is an API Foundations engineer at Shopify focused on GraphQL scalability and performance. He’s an open-source contributor on several GraphQL projects, and author of The Schema Stitching Handbook. Coder. Dad. Likes dogs, juggles fire.

Get your ticket

Join two transformative days of expert insights and innovation to shape the next decade of APIs!

Get tickets
COMMUNITYDEVELOPER EXPERIENCEAPIsTOOLS & LIBRARIESCOMMUNITYDEVELOPER EXPERIENCEAPIsTOOLS & LIBRARIES
OPEN SOURCEFEDERATIONECOSYSTEMSTRACING & OBSERVABILITYOPEN SOURCEFEDERATIONECOSYSTEMSTRACING & OBSERVABILITY
BEST PRACTICESWORKSHOPSSCHEMASSECURITYBEST PRACTICESWORKSHOPSSCHEMASSECURITY