|
Deprecated. |
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 |
|---|---|---|---|
|
|
none |
Name of the database index on the enum’s parent table (resolved via the |
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. -
namemust resolve to an existing database index when jOOQ index generation is enabled. The same "no matching index" error fires as for@order(index:). -
@indexand@ordercannot 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.