reviewCreate
Overview
Allow customers to submit reviews after fulfilling orders. Provide the order key, overall shipping rate, and product-specific ratings via CreateReviewPayload.
- Type: GraphQL Mutation
- Endpoint: https://subdomain.com
- Authentication:
Authorization: Bearer <TOKEN>
Mutation
mutation CreateReview($input: CreateReviewPayload!) {
createReview(input: $input) {
success
data {
_id
app
order
shippingRate
note
isApproved
productRatings {
product
rating
note
_id
}
}
message
}
}
Variables
{
"input": {
"orderKey": "<ORDER_KEY>",
"shippingRate": 4,
"note": "Great delivery",
"productRatings": [
{
"product": "<PRODUCT_ID>",
"rating": 5,
"note": "Loved the quality"
}
]
}
}
Examples
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com\
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation CreateReview($input: CreateReviewPayload!) { createReview(input: $input) { success message data { _id shippingRate productRatings { product rating } } } }",
"variables": {
"input": {
"orderKey": "<ORDER_KEY>",
"shippingRate": 4,
"productRatings": [
{ "product": "<PRODUCT_ID>", "rating": 5, "note": "Great" }
]
}
}
}
EOF
const res = await fetch('https://subdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `
mutation CreateReview($input: CreateReviewPayload!) {
createReview(input: $input) {
success
message
data { _id shippingRate productRatings { product rating } }
}
}
`,
variables: {
input: {
orderKey: '<ORDER_KEY>',
shippingRate: 4,
productRatings: [
{ product: '<PRODUCT_ID>', rating: 5, note: 'Great' },
],
},
},
}),
});
const json = await res.json();
Notes
- Validate
orderKeyserver-side to ensure the order belongs to the customer. productRatingscan include multiple entries for each purchased product/variant.- Gate review creation with rate-limiting or completion status to avoid spam.