"""
Represents a production with at least one opening or ending sequence.

For example, Bakemonogatari is an anime production with five opening sequences and one ending sequence.
"""
type Anime @model(class: "App\\Models\\Wiki\\Anime") {
    "The primary key of the resource"
    id: Int! @rename(attribute: "anime_id")

    "The primary title of the anime"
    name: String!

    "The format of the anime"
    format: AnimeFormat

    "The formatted string value of the format field"
    formatLocalized: String @localized

    "The premiere season of the anime"
    season: AnimeSeason

    "The formatted string value of the season field"
    seasonLocalized: String @localized

    "The URL slug & route key of the resource"
    slug: String!

    "The brief summary of the anime"
    synopsis: String

    "The premiere year of the anime"
    year: Int @deprecated(reason: "Use the `startDate.year` field instead.")

    "The premiere date of the anime, with a fuzzy date representation"
    startDate: FuzzyDate @rename(attribute: "start_date")

    "The end date of the anime, with a fuzzy date representation"
    endDate: FuzzyDate @rename(attribute: "end_date")

    "The URL for the anime page on the website"
    siteUrl: String! @field(resolver: "App\\GraphQL\\Types\\AnimeType@resolveSiteUrlAttribute")

    "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")

    synonyms(
        type: SynonymType @eq
        where: _ @whereConditions(columnsEnum: SynonymFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [SynonymSort!] @sort
    ): [Synonym!]! @morphMany

    animethemes(
        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!]! @hasManyCustom(type: SIMPLE)

    images(
        facet: ImageFacet @eq
        path_like: String @like(key: "path")
        where: _ @whereConditions(columnsEnum: ImageFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [ImageSort!] @sort
    ): [Image!]! @belongsToManyCustom(type: CONNECTION, edgeType: "ImageEdge")

    resources(
        site: ResourceSite @eq
        externalId: Int @eq(key: "external_id")
        where: _ @whereConditions(columnsEnum: ExternalResourceFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [ExternalResourceSort!] @sort
    ): [ExternalResource!]! @belongsToManyCustom(type: CONNECTION, edgeType: "ExternalResourceEdge")

    series(
        name_like: String @like(key: "name")
        where: _ @whereConditions(columnsEnum: SeriesFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [SeriesSort!] @sort
    ): [Series!]! @belongsToManyCustom(type: CONNECTION, edgeType: "AnimeSeriesEdge")

    studios(
        name_like: String @like(key: "name")
        where: _ @whereConditions(columnsEnum: StudioFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [StudioSort!] @sort
    ): [Studio!]! @belongsToManyCustom(type: CONNECTION, edgeType: "AnimeStudioEdge")
}

type AnimeSeriesEdge @model(class: "App\\Pivots\\Wiki\\AnimeSeries") {
    "The Series node."
    node: Series!

    "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")
}

type AnimeStudioEdge @model(class: "App\\Pivots\\Wiki\\AnimeStudio") {
    "The Studio node."
    node: Studio!

    "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")
}

extend type Query {
    "Returns an anime resource."
    anime(slug: String! @eq): Anime @find(model: "App\\Models\\Wiki\\Anime")

    "Filter anime by its external id on given site."
    findAnimeByExternalSite(
        site: ResourceSite!
        id: [Int!]
        link: String
    ): [Anime!]! @builder(method: "App\\GraphQL\\Builders\\FindAnimeByExternalSiteBuilder") @all

    "Returns a listing of anime resources given fields."
    animePagination(
        id: Int @eq(key: "anime_id")
        search: String @search
        name: String @eq
        name_like: String @like(key: "name")
        format: AnimeFormat @eq
        format_in: [AnimeFormat!] @in(key: "format")
        season: AnimeSeason @eq
        season_in: [AnimeSeason!] @in(key: "season")
        slug: String @eq
        year: Int @eq @deprecated(reason: "Use the `startDate` filter instead.")
        year_lesser: Int @where(operator: "<", key: "year") @deprecated(reason: "Use the `startDate_lesser` filter instead.")
        year_greater: Int @where(operator: ">", key: "year") @deprecated(reason: "Use the `startDate_greater` filter instead.")
        startDate: FuzzyDateInt @eq(key: "start_date")
        startDate_lesser: FuzzyDateInt @where(operator: "<", key: "start_date")
        startDate_greater: FuzzyDateInt @where(operator: ">", key: "start_date")
        endDate: FuzzyDateInt @eq(key: "end_date")
        endDate_lesser: FuzzyDateInt @where(operator: "<", key: "end_date")
        endDate_greater: FuzzyDateInt @where(operator: ">", key: "end_date")
        where: _ @whereConditions(columnsEnum: AnimeFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [AnimeSort!] @sort
    ): [Anime!]! @paginate
}