"A date string with format `Y-m-d`, e.g. `2011-05-23`."
scalar Date @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\Date")
scalar Year

extend type Query{
     "Paginate items"
    items: [Item!]! @paginate @guard

    "Item by Id"
    item(id: Int! @eq): Item @find @guard

    allItems: [Item!]! @all @guard

    topItems(query: String, init_date: Date, end_date: Date): [Item!]! @guard @paginate(builder: "App\\GraphQL\\Queries\\TopItems")

    searchItem(item: String!): [Item!]! @guard

    textSearchItems(query: String!): [Item!]!

    "Item My Stats"
    itemStats(query: String, init_date: Date, end_date: Date): [String]! @guard @paginate(builder: "App\\GraphQL\\Queries\\ItemStats")

    "Top Category By User"
    # topCategoryByUser(query: String): [CategoryItem!] @guard @paginate(builder: "App\\GraphQL\\Queries\\TopCategoryByUser")
    topCategoryByUser(query: String, init_date: Date, end_date: Date): [String!] @guard
}

type Item{
    id: ID!

    name: String!

    description: String

    totalAmount: Float! @method(name: "totalAmount")

    image: String

    model: ItemModel @hasOne

    version: String

    brand: Brand @hasOne

    manufacturer: Manufacturer @hasOne

    year_of_production: Year

    "Follwers relationship."
    sectors: [Sector]! @belongsToMany(relation: "sectors")

    "Categories relationship"
    categories: [CategoryItem] @belongsToMany(relation: "categories")

    "SubCategories relationship"
    subcategories: [SubCategoryItem] @belongsToMany(relation: "subcategories")

    purchases: [Purchase] @hasMany(relation: "purchases")

}

type CategoryItem {
    id:ID!
    name: String!
    description: String
}

type SubCategoryItem {
    id:ID!
    name: String!
    description: String
}

type ItemModel {
    id:ID!
    name: String!
    description: String
}

type ExperienceItem {
    id: ID!

    experience: Int!

    user_id: ID!

    item_id: ID!

    item: Item @hasOne

    user: User @hasOne

    comment: String
}