GraphQL persisted queries and Schema stability
Zalando disables arbitrary GraphQL queries in production and accepts only query IDs that were persisted at build time, where an ID is a hash of the normalized query. Because every production query is known, the team can monitor and alert per query and tell which schema fields are unused and therefore safe to break. On top of this they add schema directives: @draft blocks a field from being persisted so it can be merged, deployed and changed freely. @component and @allowedFor restrict an experimental field to specific UI components, so a breaking change only touches those callers. Fields move from draft to restricted to stable, which lets the schema evolve without long-lived feature branches across microservices.
Related posts
- 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.
- 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.
- What's New in pg_graphql v1.2
Supabase mediumAdeptpg_graphql v1.1–1.2 now reflects views, materialized views and foreign tables into the GraphQL schema, with primary keys declared via a comment directive. Simple views also support inserts and updates, which can keep older API shapes working while the underlying tables are migrated. Filtering gains `is: NULL/NOT_NULL` on every scalar filter plus `like`, `ilike` and `startsWith` on strings; `startsWith` is preferred because it can use plain B-tree indexes. The release also implements the spec's `@skip`/`@include` directives and lets users set table and column descriptions through comment directives, and requires Postgres 15.1.0.63 or later.
- Modeling Errors in GraphQL
Zalando Engineering mediumAdeptGraphQL's built-in errors array is untyped and undiscoverable, so Zalando splits failures into two categories based on who can act on them. Errors stay in response.errors with an extensions.code (NOT_FOUND, NOT_AUTHORIZED, or no code for internal failures) and keep GraphQL's null-propagation semantics. Problems, named after RFC 7807, are schema types returned through Success/Problem result unions with translated messages. They are reserved mainly for mutation input validation, where only the customer can fix the issue. Using Problem types everywhere would bloat queries and front-end branching, so they should be used sparingly.
- Migrating from Apollo Tooling to GraphQL Codegen at Yelp
Yelp Engineering mediumAdeptYelp replaced the deprecated apollo-tooling codegen with GraphQL Codegen across a 500+ package React/TypeScript monorepo without requiring developers to change imports or queries. Rather than adopting gql.tada or Codegen's native client preset, the team patched the typescript-operations plugin and near-operation-file preset to emit apollo-tooling-compatible output: per-operation file names, inlined enums and input types, plain `T | null` instead of Maybe/Exact wrappers, and field-only nested type names. The patches also fixed a concurrency problem where multiple processes regenerated shared fragments. The changes were upstreamed into GraphQL Codegen v6 in collaboration with its maintainer. The remaining few hundred type errors were fixed incrementally, with Claude's help, using a shrinking allowlist of packages still on the old tool.