Acesso Comercial / Docs / Storefront / API
Ctrl K
MUTATION

createReview

Cria uma avaliação para um produto. Requer autenticação do cliente.

Requer autenticação: O cliente precisa estar logado via clientLogin.

Input

CreateReviewMutationInput!

CampoTipoDescrição
hostnameString!Hostname da loja.
productIdID!ID global Relay do produto.
starsInt!Nota de 1 a 5 estrelas.
textString!Texto da avaliação.

Retorno

CampoTipoDescrição
reviewReviewAvaliação criada.

Mutation

GraphQL
mutation AddReview($input: CreateReviewMutationInput!) {
  createReview(input: $input) {
    review {
      id
      stars
      text
      createdAt
    }
  }
}

Variables

JSON
{
  "input": {
    "hostname": "minha-loja",
    "productId": "UHJvZHVjdDphYmMx",
    "stars": 5,
    "text": "Produto excelente! Entrega rápida."
  }
}

Resposta

JSON
{
  "data": {
    "createReview": {
      "review": {
        "id": "review1",
        "stars": 5,
        "text": "Produto excelente! Entrega rápida.",
        "createdAt": "2026-06-10T15:00:00Z"
      }
    }
  }
}

Fetch

JavaScript
const response = await fetch('/graphql', {
  method: 'POST',
  credentials: 'include',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    query: `mutation($input: CreateReviewInput!) {
      createReview(input: $input) { success }
    }`,
    variables: { input: { hostname: "minha-loja", productId: "UHJvZHVjdDphYmMx", stars: 5, comment: "Excelente produto!" } }
  })
});

cURL

Bash
curl -X POST https://minha-loja.com/graphql \
  -H "Content-Type: application/json" \
  -b "authJwtClient=YOUR_SESSION_COOKIE" \
  -d '{"query":"mutation { createReview(input: { hostname: \"minha-loja\", productId: \"UHJvZHVjdDphYmMx\", stars: 5, comment: \"Excelente!\" }) { success } }"}'