At a glance
- Identifier: #997
- Stage: RFC 1 / Proposal
- Champion: @fotoetienne
- Latest activity: Added to WG agenda on 2025-06-26
- Spec PR: https://github.com/graphql/graphql-spec/pull/997
Spec PR description
Problem
Take as a motivating example:
type Query {
animals: [Animal]
}
interface Animal {
name: String
}
type Dog implements Animal {
name: String
}
type Baiji implements Animal {
name: String
}
The Baiji type corresponds to an Animal that is no longer known to exist, and the server will no longer return this type. We would like to delete the code for this type and eventually remove from the schema, but first clients must remove all references of this type from their queries. Currently, there is no good way to indicate to clients that they should no longer spread on this type in their queries.
Solution
Allow @deprecated on objects. Marking as deprecated indicates to clients that this type will no longer be returned from the server. This can indicate to client build tooling that references to this object should be removed from client queries.
type Baiji implements Animal @deprecated {
name: String
}
Alternative Solutions
The most compelling use-case for deprecating types is when they are union members or interface implementations. A potential alternative would be to instead deprecate the membership/implementation instead of the type itself. The main challenge with this approach is with syntax, since it unclear how one would unambiguously annotate an interface implementation using the current @deprecated directive. Some possible alternatives:
New directive location - @deprecated on UNION_MEMBER
union Animal = Dog | Cat | Baiji @deprecated
New directive @deprecatedMembers on UNION
union Animal @deprecatedMembers(members: ["Baiji"]) = Dog | Cat | Baiji
New directive @deprecatedImplementations on OBJECT
type Baiji implements Node & Animal @deprecatedImplementations(implementations: ["Animal"]) {
id: ID!
name: String
}
New directive @deprecatedImplementations on INTERFACE
interface Animal @deprecatedImplementations(implementations: ["Baiji"]) {
id: ID!
name: String
}
Timeline
- Added to WG agenda on 2025-06-26
- Added to WG agenda on 2024-11-07
- Added to WG agenda on 2023-06-01
- Mentioned in WG notes on 2023-06-01
- Added to WG agenda on 2022-11-01
- Mentioned in WG notes on 2022-11-01
- Commit pushed on 2022-10-21 by fotoetienne: Add includeDeprecated argument to __type.possibleTypes
- Spec PR created on 2022-10-20 by fotoetienne
- Commit pushed on 2022-10-20 by fotoetienne: Expand @deprecated to Objects
- Added to WG agenda on 2022-10-01