"""
Represents a company that produces anime.

For example, Shaft is the studio that produced the anime Bakemonogatari.
"""
type Studio @model(class: "App\\Models\\Wiki\\Studio") {
    "The primary key of the resource"
    id: Int! @rename(attribute: "studio_id")

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

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

    "The URL for the studio page on the website"
    siteUrl: String! @field(resolver: "App\\GraphQL\\Types\\StudioType@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")

    anime(
        name_like: String @like(key: "name")
        format: AnimeFormat @eq
        format_in: [AnimeFormat!] @in(key: "format")
        season: AnimeSeason @eq
        season_in: [AnimeSeason!] @in(key: "season")
        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")
        where: _ @whereConditions(columnsEnum: AnimeFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [AnimeSort!] @sort
    ): [Anime!]! @belongsToManyCustom(type: CONNECTION, edgeType: "StudioAnimeEdge")

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

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

    "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 a studio resource."
    studio(slug: String! @eq): Studio @find(model: "App\\Models\\Wiki\\Studio")

    "Returns a listing of studio resources given fields."
    studioPagination(
        id: Int @eq(key: "studio_id")
        search: String @search
        name: String @eq
        name_like: String @like(key: "name")
        slug: String @eq
        where: _ @whereConditions(columnsEnum: StudioFilterableColumns, handler: "App\\GraphQL\\WhereConditions\\WhereConditionsHandler")
        sort: [StudioSort!] @sort
    ): [Studio!]! @paginate
}