---
title: "GraphQL persisted queries and Schema stability"
description: "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."
url: "https://swe.quest/articles/graphql-persisted-queries-and-schema-stability-a96dada14e0377f0"
canonical: "https://engineering.zalando.com/posts/2022/02/graphql-persisted-queries-and-schema-stability.html"
source: "Zalando Engineering"
published: "2022-02-16"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["graphql","api-design","schema-migrations","deployment"]
---

# GraphQL persisted queries and Schema stability

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2022-02-16, 6 min read, Case study. Original: [https://engineering.zalando.com/posts/2022/02/graphql-persisted-queries-and-schema-stability.html](https://engineering.zalando.com/posts/2022/02/graphql-persisted-queries-and-schema-stability.html)

## Summary

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.

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)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- GraphQL schemas and queries ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))
- GraphQL directives ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))
- API versioning basics

## Keywords

GraphQL, persisted queries, Apollo, Zalando, GraphQL directives

## Related posts

- [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.
- [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.
- [What's New in pg\_graphql v1.2](https://swe.quest/articles/what-s-new-in-pg-graphql-v1-2-8e0869fac360da26.md): Supabase · 2023-04-21 · Medium · 4 min read · GraphQL, PostgreSQL, API design
  pg\_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.
- [Modeling Errors in GraphQL](https://swe.quest/articles/modeling-errors-in-graphql-bde0367a83f4ea52.md): Zalando Engineering · 2021-04-12 · Medium · 10 min read · GraphQL, API design
  GraphQL's built-in errors array is untyped and undiscoverable, so Zalando splits failures into two categories based on who can act on them.
- [Migrating from Apollo Tooling to GraphQL Codegen at Yelp](https://swe.quest/articles/migrating-from-apollo-tooling-to-graphql-codegen-at-yelp-732b107d437979cc.md): Yelp Engineering · 2026-07-16 · Medium · 11 min read · GraphQL, TypeScript, Build systems, Refactoring & migrations, Open source
  Yelp replaced the deprecated apollo-tooling codegen with GraphQL Codegen across a 500+ package React/TypeScript monorepo without requiring developers to change imports or queries.

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)
