Deprecated. @index exists for backward compatibility with schemas predating @order. New code must use @order(index: "…​") instead. The framework still recognises @index and routes it to the same generator path, but the directive surface, error messages, and how-to pages all assume @order.

Connects an enum value to a database index by name. Functionally identical to @order(index: "…​") with no additional capabilities; the rename happened when @order generalised the surface to include fields: and primaryKey:.

SDL signature

directive @index(name: String) on ENUM_VALUE

Parameters

Name Type Default Description

name

String

none

Name of the database index on the enum’s parent table (resolved via the @orderBy argument that references this enum). Identical semantics to @order’s `index.

Canonical example

The legacy spelling, ordering films by the idx_fk_language_id and idx_title indexes:

type Query {
  films(order: [FilmOrderBy] @orderBy): [Film!]! @defaultOrder(primaryKey: true)
}

type Film @table(name: "film") {
  title: String @field(name: "title")
}

input FilmOrderBy {
  field: FilmOrderByField!
  direction: SortDirection
}

enum FilmOrderByField {
  LANGUAGE @index(name: "idx_fk_language_id")
  TITLE @index(name: "idx_title")
}

The equivalent modern spelling:

type Query {
  films(order: [FilmOrderBy] @orderBy): [Film!]! @defaultOrder(primaryKey: true)
}

type Film @table(name: "film") {
  title: String @field(name: "title")
}

input FilmOrderBy {
  field: FilmOrderByField!
  direction: SortDirection
}

enum FilmOrderByField {
  LANGUAGE @order(index: "idx_fk_language_id")
  TITLE @order(index: "idx_title")
}

The two forms generate identical code. The migration is a mechanical rename plus a parameter shape change (name: becomes index:).

Constraints

  • Applies only to enum values, like @order.

  • name must resolve to an existing database index when jOOQ index generation is enabled. The same "no matching index" error fires as for @order(index:).

  • @index and @order cannot both decorate the same enum value.

  • Cannot express the field-based or primary-key sorting modes available on @order. Schemas that need those modes must migrate.

Migration

Replace each @index(name: "X") with @order(index: "X"). No runtime behaviour changes; only the directive name and parameter key.

See also

  • @order is the supported replacement.

  • @orderBy is the entry point for both forms.