magento / architecture

A place where Magento architectural discussions happen
274 stars 154 forks source link

Update product review graphql schema #343

Closed sky-hub closed 4 years ago

sky-hub commented 4 years ago

Problem

  1. Can not sort reviews by other fields
  2. Reviews query does not return totals reviews
  3. Unable to access review detail page from customer account as the route requires review id.
  4. Keep field naming consistency.
  5. Missing rating percent from review ratings.
  6. Usage of "String" field type instead of "Int" when it is not the case.

Solution

  1. Review sort order

    • useful if we want to create a listing/widget with top 5 product reviews
    • default will be "created_at" DESC
  2. Add "total_count" field for "ProductReviews"

    • needed to display review totals when listing product reviews in customer account
  3. Add field "review_id" to "ProductReview"

    • needed if we want to keep the review detail page from customer account. See route "review/customer/view/id/[REVIEW_ID]" (Ex: https:www.example.com/review/customer/view/id/1/). If this page can be eliminated we can drop this field.
  4. Rename "ProductReview" field "summary" with "title" and field "text" with "review_text"

  5. Rename "CreateProductReviewInput" field "summary" with "title" and field "text" with "review_text"

  6. Rename "ProductReview" field "ratings_breakdown" with "ratings".

    • keep naming consitency with same field from "CreateProductReviewInput"
    • keep field naming as intuitive as possible
  7. Add percent field to "ProductReviewRating"

    • help to avoid calculations in frontend area if the value for this field is needed for frontend logic.
  8. Change "ProductReviewRating" field type from "string" to "int".

    • there is not need to have field type as string when Magento Core predefined values are 1 to 5 and does not allows doe users to add new values.
  9. Change "value_id" field from "ProductReviewRatingValueMetadata" to int instead of string

    • there is not need to have field type as string when Magento Core predefined values are 1 to 5 and does not allows doe users to add new values.

Note: Instead of base64 encoded values for ratings we can use the rating "Default Value" which is unique across the system, but that will mean adding a separate field for store label.

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

instead of

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

That would mean "ProductReviewRatingInput " will look like this:

type ProductReviewRatingInput {
    name: String! @doc(description: "The review rating name. For example Quality, Price")
    value: Int! @doc(description: "The rating value. Possible values: 1, 2, 3, 4, 5")
}

Requested Reviewers

@naydav @paliarush @lenaorobei

sky-hub commented 4 years ago

@lenaorobei , can I get an update on these changes? Are they still of interest? Are there any additional changes/updates required?

Thanks

nrkapoor commented 4 years ago

@sky-hub @paliarush I have added it to the backlog and will prioritize with my team. Closing this PR and will open another one once we determine the priority.

sky-hub commented 4 years ago

@nrkapoor , @paliarush , ok, just let me know if there is anything else i can help with on this matter.

Cheers