Buscar um ou mais produtos pelo ID global Relay.
| Argumento | Tipo | Descrição |
|---|---|---|
| id | ID! | ID global Relay do produto (base64-encoded). |
Retorna um objeto Product ou null caso o produto não exista.
| Argumento | Tipo | Descrição |
|---|---|---|
| ids | [ID!]! | Array de IDs globais Relay dos produtos. |
Retorna uma lista de objetos Product. Produtos não encontrados são omitidos da lista.
TipoNome:uuid. Ex: UHJvZHVjdDphYmMxMjM= decodifica para Product:abc123.
query GetProduct($id: ID!) {
product(id: $id) {
id
title
price
images { url }
}
} {
"data": {
"product": {
"id": "UHJvZHVjdDphYmMx",
"title": "Camiseta Premium",
"price": 8990,
"images": [{ "url": "https://..." }]
}
}
} query GetProducts($ids: [ID!]!) {
products(ids: $ids) {
id
title
price
images { url }
}
} {
"data": {
"products": [
{
"id": "UHJvZHVjdDphYmMx",
"title": "Camiseta Premium",
"price": 8990,
"images": [{ "url": "https://..." }]
},
{
"id": "UHJvZHVjdDpkZWYy",
"title": "Calça Jeans",
"price": 12990,
"images": [{ "url": "https://..." }]
}
]
}
} 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 -X POST https://minha-loja.com/graphql \
-H "Content-Type: application/json" \
-d '{"query":"query { product(id: \"UHJvZHVjdDphYmMx\") { id title price images { url } } }"}'