Skip to main content

Definition

Arguments

Overview

@deprecated is a built-in GraphQL directive defined in the GraphQL specification. It signals to API consumers that a schema element should no longer be used. Deprecated elements remain fully functional. The directive is a documentation and tooling signal, not a removal mechanism. GraphQL IDEs such as GraphiQL display deprecation warnings, and introspection exposes isDeprecated and deprecationReason fields so tools can surface this information automatically.

Supported locations

  • Field definitions on object and interface types.
  • Argument definitions on fields and directives.
  • Input field definitions on input object types.
  • Enum values.

Examples

Deprecating a field

Deprecating an enum value

Deprecating a field argument

Deprecating an input field

Federation behavior

During composition, if the same field or enum value is marked @deprecated in multiple subgraphs with different reasons, Cosmo keeps the longest reason string. @deprecated is preserved in both the client-facing schema and the router schema. It appears in introspection responses so that consumers can detect deprecated usage.