GraphQL can mark fields, input fields, arguments and enum values as @deprecated, with an optional reason. Tools like GraphiQL and editor integrations show it to developers.

Gratos reads the @deprecated JSDoc tag, on fields, enum values and arguments. The text after the tag, if any, is the reason.

Field example

User.ts
/** @gqlType */
class User {
  /**
   * @gqlField
   * @deprecated Please use newField instead.
   */
  oldField: string;

  /** @gqlField */
  newField: string;

  constructor(oldField: string, newField: string) {
    this.oldField = oldField;
    this.newField = newField;
  }
}

Overlap with TypeScript's @deprecated

TypeScript also treats a construct whose docblock has @deprecated specially: the editor shows its uses struck through and greyed out. In general this overlap is a feature, since your own code should not use a deprecated field either. But if you want to deprecate a field, an argument or another construct in your schema and not in your code, define a method or function for GraphQL only, which wraps the one that is not deprecated:

User.ts
/** @gqlType */
class User {
  // Not deprecated!
  name: string;

  constructor(name: string) {
    this.name = name;
  }

  /**
   * @gqlField name
   * @deprecated Not supported externally any more
   */
  graphQLName(): string {
    return this.name;
  }
}