Reviews
This article contains all actions for retrieving and managing reviews.
Get review by ID#
query {
getReview(id: "1") {
id
siteid
customerid
orderproductid
domain
refid
name
comment
response
rating
status
mtime
ctime
editor
}
}
const body = JSON.stringify({'query':
`query {
getReview(id: "1") {
id
siteid
customerid
orderproductid
domain
refid
name
comment
response
rating
status
mtime
ctime
editor
}
}`});
fetch($('.aimeos').data('graphql'), {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"getReview": {
"id": "13",
"siteid": "1.",
"customerid": "6",
"orderproductid": "7",
"domain": "product",
"refid": "52",
"name": "test",
"comment": "",
"response": "",
"rating": 1,
"status": -1,
"mtime": "2022-08-22 11:42:22",
"ctime": "2022-08-22 11:42:22",
"editor": "aimeos@aimeos.org"
}
}
}
Search reviews#
The filter parameter is explained in the filter section of the GraphQL basics article.
query {
searchReviews(filter: "{\"=~\": {\"review.code\":\"demo-\"}}") {
id
siteid
customerid
orderproductid
domain
refid
name
comment
response
rating
status
mtime
ctime
editor
}
}
let filter = {
"=~": {"review.code":"demo-"}
};
const fstr = JSON.stringify(JSON.stringify(filter));
const body = JSON.stringify({'query':
`query {
searchReviews(filter: ` + fstr + `) {
id
siteid
customerid
orderproductid
domain
refid
name
comment
response
rating
status
mtime
ctime
editor
}
}`});
fetch($('.aimeos').data('graphql'), {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"searchReviews": [
{
"id": "13",
"siteid": "1.",
"customerid": "6",
"orderproductid": "7",
"domain": "product",
"refid": "52",
"name": "test",
"comment": "",
"response": "",
"rating": 1,
"status": -1,
"mtime": "2022-08-22 11:42:22",
"ctime": "2022-08-22 11:42:22",
"editor": "aimeos@aimeos.org"
}
]
}
}
Save single review#
mutation {
saveReview(input: {
id: "1"
status: 1
response: "Thanks a lot!"
}) {
id
}
}
const body = JSON.stringify({'query':
`mutation {
saveReview(input: {
id: "1"
status: 1
response: "Thanks a lot!"
}) {
id
}
}`});
fetch($('.aimeos').data('graphql'), {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"saveReview": {
"id": "1"
}
}
}
Save multiple reviews#
mutation {
saveReviews(input: [{
id: "1"
status: 1
response: "Thanks a lot too!"
},{
id: "2"
status: 0
}]) {
id
}
}
const body = JSON.stringify({'query':
`mutation {
saveReviews(input: [{
id: "1"
status: 1
response: "Thanks a lot too!"
},{
id: "2"
status: 0
}]) {
id
}
}`});
fetch($('.aimeos').data('graphql'), {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"saveReviews": [
{
"id": "1"
},
{
"id": "2"
}
]
}
}
Delete single review#
mutation {
deleteReview(id: "2")
}
const body = JSON.stringify({'query':
`mutation {
deleteReview(id: "2")
}`});
fetch($('.aimeos').data('graphql'), {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"deleteReview": "2"
}
}
Delete multiple reviews#
mutation {
deleteReviews(id: ["1", "2"])
}
const body = JSON.stringify({'query':
`mutation {
deleteReviews(id: ["1", "2"])
}`});
fetch($('.aimeos').data('graphql'), {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"deleteReviews": [
"1",
"2"
]
}
}