---
title: "Optimize GraphQL Server with Lookaheads"
description: "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."
url: "https://swe.quest/articles/optimize-graphql-server-with-lookaheads-2ec291286b4baa0c"
canonical: "https://engineering.zalando.com/posts/2021/03/optimize-graphql-server-with-lookaheads.html"
source: "Zalando Engineering"
published: "2021-03-17"
difficulty: "medium"
kind: "How-to"
reading_minutes: 12
tags: ["graphql","api-design","performance","javascript"]
---

# Optimize GraphQL Server with Lookaheads

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2021-03-17, 12 min read, How-to. Original: [https://engineering.zalando.com/posts/2021/03/optimize-graphql-server-with-lookaheads.html](https://engineering.zalando.com/posts/2021/03/optimize-graphql-server-with-lookaheads.html)

## Summary

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. Dependency maps translate schema fields to backend object paths for the request, and per-field transformer maps build the schema response from partial backend data without null-check sprawl. DataLoader batches product lookups across a query by merging ids and taking the union of requested backend fields, since most backends can't select different fields per id.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [GraphQL](https://swe.quest/tags/graphql.md) (Backend & APIs)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- GraphQL resolvers ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))
- GraphQL query AST ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))
- DataLoader batching

## Keywords

GraphQL, DataLoader, GraphQL-JIT, GraphQL-JS, Zalando

## 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.
- [Shopify’s journey to faster breadth-first GraphQL execution](https://swe.quest/articles/shopify-s-journey-to-faster-breadth-first-graphql-execution-83f0f58b8c4dabd1.md): Shopify Engineering · 2026-03-12 · Hard · 14 min read · GraphQL, Performance engineering, Ruby, Query engines
  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.
- [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.
- [Understanding GraphQL Directives: Practical Use-Cases at Zalando](https://swe.quest/articles/understanding-graphql-directives-practical-use-cases-at-zalando-20796a0cce64c9f9.md): Zalando Engineering · 2023-10-18 · Medium · 12 min read · GraphQL, API design, Identity & auth, Observability
  Zalando uses custom GraphQL directives to declare cross-cutting server behavior in the schema and to attach client metadata in queries.
- [Micro Frontends: Deep Dive into Rendering Engine (Part 2)](https://swe.quest/articles/micro-frontends-deep-dive-into-rendering-engine-part-2-9a2ff0104826dc54.md): Zalando Engineering · 2021-09-08 · Medium · 12 min read · Frontend, React, System design, GraphQL, TypeScript
  Zalando's Interface Framework replaces Mosaic HTML fragments with Renderers: declarative TypeScript modules that state their data needs as GraphQL queries and render a single Entity type as a React component.

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)
