Optimize GraphQL Server with Lookaheads
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.
Related posts
- How we use GraphQL at Europe's largest fashion e-commerce company
Zalando Engineering easyNoviceZalando 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. The BFFs had duplicated effort, fragmented security and observability, and produced inconsistent data across web and app. The graph is built on Entities such as Product and Campaign and runs on their own GraphQL engine, graphql-jit, under a strict no-business-logic rule. Since 2018 it has grown to serve over 80% of web and 50% of app use cases, with adoption driven by documentation, training and schema consultation, and god-component risk handled through contribution principles, circuit breakers, timeouts, retries and per-platform bulkhead deployments.
- Shopify’s journey to faster breadth-first GraphQL execution
Shopify Engineering hardMasterShopify 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.
- Querying Strategies for GraphQL Clients
Shopify Engineering mediumAdeptGraphQL 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. Starting from a single products query, they add cursor-style pagination with page-size parameters and hasNextPage, and gate new fields behind feature flags using @include/@skip directives. Chaining queries on remote flags is costly because it serializes round-trips, so it should be avoided or moved app-wide. Splitting non-paginated parts such as filters, permissions and banners into parallel queries enables faster loads, partial rendering and fewer merge conflicts, provided performance tripwires and server-side monitoring are in place.
- Understanding GraphQL Directives: Practical Use-Cases at Zalando
Zalando Engineering mediumAdeptZalando uses custom GraphQL directives to declare cross-cutting server behavior in the schema and to attach client metadata in queries. Schema directives handle field-level authentication with ACR levels (@isAuthenticated), redacting sensitive arguments from logs and traces (@sensitive, backed by a keyword linter), restricting fields to dedicated HTTP endpoints for rate limiting and bot protection (@requireExplicitEndpoint), and gating persisted queries by schema stability (@draft, @allowedFor). They also control enum evolution for mobile clients (@final, @extensibleEnum) and generate entity ID boilerplate (@resolveEntityId). Query directives such as @component, @tracingTag and @omitErrorTag feed OpenTelemetry tracing and alerting, using a two-step AST extraction before execution and error-path matching after it.
- Micro Frontends: Deep Dive into Rendering Engine (Part 2)
Zalando Engineering mediumAdeptZalando'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. A Node.js Rendering Engine maps Entities to Renderers through rendering rules, recursively and asynchronously resolves the entity tree, and streams server-rendered HTML that is later progressively hydrated on the client. A custom React reconciler lets the same Renderers emit JSON layouts for the iOS and Android apps. The engine also handles batched, cached data fetching (DataLoader, Perron circuit breakers), persisted queries, code splitting, Web Vitals collection and Mosaic backward compatibility.