Przejdź do głównej zawartości

updateProduct

Dla: Programista

MutacjaBetaMutation.updateProduct

Changes a product: fields left out keep their values. The order must not be archived. Sending the same values again changes nothing, not even Order.updatedAt.

Wymagany zakresorders:write
Dostępne odPrynt 0.28.0
StabilnośćBeta (co to znaczy)
PonawianieOperacja idempotentna: ponowienie bez nagłówka Idempotency-Key jest bezpieczne. Zapisy i idempotencja

Argumenty

NazwaTypOpis
idwymaganeID!

Identifier of the product to change.

inputwymaganeUpdateProductInput!

What to change: fields left out keep their values. An explicit null is refused unless the field says otherwise.

Zwraca

Product!

Przykład

Mutacja
mutation ChangeProduct($id: ID!, $input: UpdateProductInput!) {
updateProduct(id: $id, input: $input) {
id
name
quantity
unit
}
}
Zmienne
{
"id": "be5a7192-4d6f-4a81-9cad-2e3f4a5b6c74",
"input": {
"quantity": 1000,
"price": 190
}
}
Wywołanie (curl)
curl -sS https://twoja-drukarnia.prynt.pl/api/v1/graphql \
-H "Authorization: Bearer $PRYNT_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"query": "mutation ChangeProduct($id: ID!, $input: UpdateProductInput!) {\n updateProduct(id: $id, input: $input) {\n id\n name\n quantity\n unit\n }\n}",
"variables": {
"id": "be5a7192-4d6f-4a81-9cad-2e3f4a5b6c74",
"input": {
"quantity": 1000,
"price": 190
}
}
}
JSON
Odpowiedź
{
"data": {
"updateProduct": {
"id": "be5a7192-4d6f-4a81-9cad-2e3f4a5b6c74",
"name": "Wizytówki",
"quantity": 1000,
"unit": "PIECES"
}
}
}