API-82Recommended
Deprecate GraphQL fields before you remove them
Change a GraphQL schema by adding types and fields, never by versioning the endpoint. Mark a field you plan to remove with @deprecated(reason:) and remove it only after 90 days with no use.
How to do it
A GraphQL client gets only the fields it asks for, so a new field breaks no one. That is why graphql.org advises a schema without versions. The @deprecated directive shows in tools and generated clients, and the reason names the field to use instead. The September 2025 edition of the specification also allows deprecating arguments and input fields. Count use per field in your traces, and remove a field only when the count is zero. The REST form of this is make only additive changes.
Examples
Plain text example
type Invoice {
id: ID!
totalCents: Int!
currency: String!
total: Float @deprecated(reason: "Use totalCents and currency. Removed after 2027-02-01.")
}
JavaScript example
// Apollo Server reads @deprecated from the schema and reports use per field
const typeDefs = gql`
type Invoice {
id: ID!
totalCents: Int!
total: Float @deprecated(reason: "Use totalCents and currency.")
}
`;
Python example
@strawberry.type
class Invoice:
id: strawberry.ID
total_cents: int
total: float | None = strawberry.field(deprecation_reason="Use total_cents and currency.")
How to check
CI compares the new schema with the live one and fails on a removed or changed field that was not marked deprecated for 90 days. Field use metrics show zero calls over the last 30 days for each field removed.
Sources
Related rules
- API-27 Make only additive changes in API design
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/graphql-and-grpc/graphql-deprecation">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.