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.