"""
Represents an OP or ED sequence for an anime.

For example, the anime Bakemonogatari has five OP anime themes and one ED anime theme.
"""
type AnimeTheme @model(class: "App\\Models\\Wiki\\Anime\\AnimeTheme") {
    "The primary key of the resource"
    id: Int! @rename(attribute: "theme_id")

    "The type of the sequence"
    type: ThemeType!

    "The formatted string value of the type field"
    typeLocalized: String! @localized

    "The numeric ordering of the theme"
    sequence: Int

    "The slug that represents the anime theme."
    slug: String!

    "The date that the resource was created"
    createdAt(format: String! = "Y-m-d H:i:s"): String @timestamp(attribute: "created_at")

    "The date that the resource was updated"
    updatedAt(format: String! = "Y-m-d H:i:s"): String @timestamp(attribute: "updated_at")

    anime: Anime! @belongsTo

    song: Song @belongsTo

    group: ThemeGroup @belongsTo

    animethemeentries(
        episodes: String @eq
        episodes_like: String @like(key: "episodes")
        nsfw: Boolean @eq
        spoiler: Boolean @eq
        version: Int @eq
        version_lesser: Int @where(operator: "<", key: "version")
        version_greater: Int @where(operator: ">", key: "version")
        where: _ @whereConditions(columnsEnum: AnimeThemeEntryFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [AnimeThemeEntrySort!] @sort
    ): [AnimeThemeEntry!]! @hasManyCustom(type: SIMPLE)
}

extend type Query {
    "Shuffle themes."
    animethemeShuffle(
        type: [ThemeType!]
        format: [AnimeFormat!]
        year_lte: Int
        year_gte: Int
        spoiler: Boolean
        first: Int
        page: Int
    ): [AnimeTheme!]! @field(resolver: "App\\GraphQL\\Queries\\AnimeThemeShuffleQuery")

    "Returns a listing of anime themes resources given fields."
    animethemePagination(
        id: Int @eq(key: "theme_id")
        search: String @search
        type: ThemeType @eq
        type_in: [ThemeType!] @in(key: "type")
        sequence: Int @eq
        sequence_lesser: Int @where(operator: "<", key: "sequence")
        sequence_greater: Int @where(operator: ">", key: "sequence")
        slug: String @eq
        where: _ @whereConditions(columnsEnum: AnimeThemeFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [AnimeThemeSort!] @sort
    ): [AnimeTheme!]! @paginate
}