Consultas
productReviews
Lista reseñas públicas con paginación por cursor, búsqueda, rating y orden.
Última actualización:
productReviews devuelve las reseñas publicadas de un producto visible. Usa nextCursor para continuar sin construir offsets ni interpretar el cursor.
Firma
productReviews(
productId: String!
limit: Int
cursor: String
search: String
sortBy: String
sortDirection: SortDirection
rating: Int
): CursorPaginatedItemsOfStorefrontReviewDto!Argumentos
| Argumento | Predeterminado | Reglas |
|---|---|---|
productId | — | Obligatorio. ID público opaco válido. |
limit | 20 | Entre 1 y 200. |
cursor | null | Cursor opaco devuelto por la página anterior; máximo 2000 caracteres. |
search | null | Texto libre de hasta 200 caracteres. |
sortBy | null | createdOn o rating, sin distinguir mayúsculas. |
sortDirection | Depende del campo | ASC o DESC. Solo se aplica al ordenar por rating; para createdOn el orden siempre es DESC. |
rating | null | Entero entre 1 y 5. |
Retorno
| Campo | Tipo | Descripción |
|---|---|---|
data | [StorefrontReviewDto!]! | Reseñas de la página actual. |
hasNextPage | Boolean! | Indica si existe otra página. |
nextCursor | String | Cursor opaco para la siguiente consulta. |
totalCount | Long | Total de reseñas que cumplen los filtros, cuando está disponible. |
Cada reseña expone id: String!, productId: String!, isVerifiedPurchase: Boolean!, rating: Int!, title: String, content: String!, reviewerName: String y createdOn: DateTime!.
Query
query ProductReviews(
$productId: String!
$limit: Int
$cursor: String
$rating: Int
) {
productReviews(
productId: $productId
limit: $limit
cursor: $cursor
rating: $rating
sortBy: "createdOn"
) {
data {
id
productId
isVerifiedPurchase
rating
title
content
reviewerName
createdOn
}
hasNextPage
nextCursor
totalCount
}
}{
"productId": "456",
"limit": 20,
"cursor": null,
"rating": 5
}cURL
curl --request POST "https://storefront.ecomiq.pe/graphql" \
--header "Content-Type: application/json" \
--header "x-Store-Domain: mi-tienda" \
--data-binary '{
"query": "query ProductReviews($productId: String!, $limit: Int, $cursor: String, $rating: Int) { productReviews(productId: $productId, limit: $limit, cursor: $cursor, rating: $rating, sortBy: \"createdOn\") { data { id productId isVerifiedPurchase rating title content reviewerName createdOn } hasNextPage nextCursor totalCount } }",
"variables": {
"productId": "456",
"limit": 20,
"cursor": null,
"rating": 5
}
}'Respuesta
{
"data": {
"productReviews": {
"data": [
{
"id": "review-1",
"productId": "456",
"isVerifiedPurchase": true,
"rating": 5,
"title": "Excelente",
"content": "Reseña útil",
"reviewerName": "Ana",
"createdOn": "2026-08-25T15:30:00Z"
}
],
"hasNextPage": true,
"nextCursor": "eyJpZCI6InJldmlldy0xIn0=",
"totalCount": 31
}
}
}En la siguiente petición, envía nextCursor sin decodificarlo ni modificarlo. Si hasNextPage es false, nextCursor será null.
Errores
| Código | Cuándo ocurre |
|---|---|
BAD_USER_INPUT | El ID, límite, cursor, búsqueda, orden o rating no cumple el contrato. |
STORE_CONTEXT_REQUIRED | x-Store-Domain no permite resolver una tienda. |