createProductReview mutation

The createProductReview mutation adds a review for the specified product. Use the productReviewRatingsMetadata query to return a list of rating categories and possible values.

Syntax

createProductReview(input: CreateProductReviewInput!): CreateProductReviewOutput!

Example usage

In the following example, Roni gives product WH08 four stars overall, three stars for value, and four stars for quality.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
mutation {
  createProductReview(
    input: {
      sku: "WH08",
      nickname: "Roni",
      summary: "Great looking sweatshirt",
      text: "This sweatshirt looks and feels great. The zipper sometimes sticks a bit.",
      ratings: [
        {
          id: "NA==",
          value_id: "MTk="
        }, {
          id: "MQ==",
          value_id: "NA=="
        }, {
          id: "Mg==",
          value_id: "OA=="
        }
      ]
    }
) {
    review {
      nickname
      summary
      text
      average_rating
      ratings_breakdown {
        name
        value
      }
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
  "data": {
    "createProductReview": {
      "review": {
        "nickname": "Roni",
        "summary": "Great looking sweatshirt",
        "text": "This sweatshirt looks and feels great. The zipper sometimes sticks a bit.",
        "average_rating": 73.33,
        "ratings_breakdown": [
          {
            "name": "Quality",
            "value": "4"
          },
          {
            "name": "Value",
            "value": "3"
          },
          {
            "name": "Overall",
            "value": "4"
          }
        ]
      }
    }
  }
}

Input attributes

The CreateProductReviewInput input object defines the product review.

CreateProductReviewInput attributes

The CreateProductReviewInput object contains the following attributes:

Attribute Data Type Description
nickname String! The customer’s nickname. Defaults to the customer name, if logged in
ratings [ProductReviewRatingInput!]! Ratings details by category. e.g price: 5, quality: 4 etc
sku String! The SKU of the reviewed product
summary String! The summary (title) of the review
text String! The review text.

ProductReviewRatingInput attributes

The ProductReviewRatingInput object contains the following attributes:

Attribute Data Type Description
id String! An encoded rating ID
value_id String! An encoded rating value ID

Output attributes

The CreateProductReviewOutput output object contains the following attribute:

Attribute Data Type Description
review ProductReview! Contains the completed product review

ProductReview attributes

The ProductReview object contains details about a product review. It contains the following attributes.

Attribute Data Type Description
average_rating Float! The average rating for product review
created_at String! Date indicating when the review was created
nickname String! The customer’s nickname. Defaults to the customer name, if logged in
product ProductInterface! Contains details about the reviewed product
ratings_breakdown [ProductReviewRating!]! An array of ratings by rating category, such as quality, price, and value
summary String! The summary (title) of the review
text String! The review text

ProductReviewRating attributes

The ProductReviewRating object contains the following attributes.

Attribute Data Type Description
name String! The label assigned to an aspect of a product that is being rated, such as quality or price
value String! The rating value given by customer. By default, possible values range from 1 to 5