type Customer {
    reviews(
        pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once."), 
        currentPage: Int = 1 @doc(description: "Specifies which page of results to return."), 
    ): ProductReviews! 
}

type ProductInterface {
    average_review_rating: Float!  @doc(description: "The average of all the ratings given to the product.") 
    review_count: Int!  @doc(description: "The total count of all the reviews given to the product.") 
    reviews(
        pageSize: Int = 20 @doc(description: "Specifies the maximum number of results to return at once."), 
        currentPage: Int = 1 @doc(description: "Specifies which page of results to return."), 
    ): ProductReviews! 
}

type ProductReviews {
    items: [ProductReview]!  @doc(description: "An array of product reviews.") 
    page_info: SearchResultPageInfo!  @doc(description: "Metadata for pagination rendering.") 
}

type ProductReview @doc(description: "Details of a product review") {
    product: ProductInterface!  @doc(description: "Contains details about the reviewed product")
    summary: String!  @doc(description: "The review summary (a.k.a title")
    text: String!  @doc(description: "The review text.") 
    nickname: String!  @doc(description: "The customer's nickname.  Defaults to customer name if logged in.") 
    created_at: String!  @doc(description: "Date indicating when the review was created.") 
    average_rating: Float!  @doc(description: "The average rating for product review.") 
    ratings_breakdown: [ProductReviewRating!]!  @doc(description: "An array of ratings by rating category.  For example quality, price.") 
}

type ProductReviewRating {
    name: String!  @doc(description: "The review rating name for example quality, price.") 
    value: String!  @doc(description: "The rating value given by customer.  Possible values by default: 1 to 5.") 
}


type Query {
    productReviewRatingsMetadata(): ProductReviewRatingsMetadata!  @doc(description: "Metadata required by clients to render ratings & reviews section.") 
}

type ProductReviewRatingsMetadata {
    items: [ProductReviewRatingMetadata!]!  @doc(description: "List of product reviews sorted based on position")
}

type ProductReviewRatingMetadata {
    id: String!  @doc(description: "Base 64 encoded rating id.")
    name: String!  @doc(description: "The review rating name for example quality, price")
    values: [ProductReviewRatingValueMetadata!]!  @doc(description: "List of product review ratings sorted based on position.") 
}

type ProductReviewRatingValueMetadata {
    value_id: String!  @doc(description: "Base 64 encoded rating value id.")
    value: String!  @doc(description: "e.g Good, Perfect, 3, 4, 5")
}

type Mutation {
    createProductReview(input: CreateProductReviewInput!):  CreateProductReviewOutput! 
}

type CreateProductReviewOutput {
    review: ProductReview! 
}

input CreateProductReviewInput {
    sku: String!  @doc(description: "The SKU of the product that the review is assigned")
    nickname: String!  @doc(description: "The customer's nickname.  Defaults to customer name if logged in.") 
    summary: String!  @doc(description: "The review summary (a.k.a title")
    text: String!  @doc(description: "The review text.") 
    ratings: [ProductReviewRatingInput!]!  @doc(description: "Ratings details by category.  e.g price: 5, quality: 4 etc")
}

type ProductReviewRatingInput {
    id: String!  @doc(description: "Base 64 encoded rating id.")
    value_id: String!  @doc(description: "Base 64 encoded rating value id.")
}
