Acesso Comercial / Docs / Storefront / API
Ctrl K
QUERY

product / products

Buscar um ou mais produtos pelo ID global Relay.

product — Buscar um produto

ArgumentoTipoDescrição
idID!ID global Relay do produto (base64-encoded).

Retorno

Retorna um objeto Product ou null caso o produto não exista.

products — Buscar múltiplos produtos

ArgumentoTipoDescrição
ids[ID!]!Array de IDs globais Relay dos produtos.

Retorno

Retorna uma lista de objetos Product. Produtos não encontrados são omitidos da lista.

IDs Relay: Os IDs são strings base64 no formato TipoNome:uuid. Ex: UHJvZHVjdDphYmMxMjM= decodifica para Product:abc123.

Query — product

GraphQL
query GetProduct($id: ID!) {
  product(id: $id) {
    id
    title
    price
    images { url }
  }
}

Resposta

JSON
{
  "data": {
    "product": {
      "id": "UHJvZHVjdDphYmMx",
      "title": "Camiseta Premium",
      "price": 8990,
      "images": [{ "url": "https://..." }]
    }
  }
}

Query — products (batch)

GraphQL
query GetProducts($ids: [ID!]!) {
  products(ids: $ids) {
    id
    title
    price
    images { url }
  }
}

Resposta

JSON
{
  "data": {
    "products": [
      {
        "id": "UHJvZHVjdDphYmMx",
        "title": "Camiseta Premium",
        "price": 8990,
        "images": [{ "url": "https://..." }]
      },
      {
        "id": "UHJvZHVjdDpkZWYy",
        "title": "Calça Jeans",
        "price": 12990,
        "images": [{ "url": "https://..." }]
      }
    ]
  }
}

Fetch

JavaScript
const response = await fetch(
  '/graphql',
  {
    method: 'POST',
    credentials: 'include',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      query: `query($id: ID!) {
        product(id: $id) { id title price images { url } }
      }`,
      variables: { id: "UHJvZHVjdDphYmMx" }
    })
  }
);
const data = await response.json();

cURL

Bash
curl -X POST https://minha-loja.com/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"query { product(id: \"UHJvZHVjdDphYmMx\") { id title price images { url } } }"}'