convertQuantity
Requires an authenticated session.
Convert a quantity from one unit to another. Both units must be in the same category. Send productId to use that product's own pack conversions when it has them. Converting a unit to itself returns the quantity unchanged.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
query ConvertQuantity($data: ConvertQuantityInput!) {
convertQuantity(data: $data) {
conversionFactor
convertedQuantity
formatted
fromUOM {
id
code
colorCode
name
pluralName
createdAt
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "query ConvertQuantity($data: ConvertQuantityInput!) {\n convertQuantity(data: $data) {\n conversionFactor\n convertedQuantity\n formatted\n fromUOM {\n id\n code\n colorCode\n name\n pluralName\n createdAt\n }\n }\n}",
"variables": {
"data": {
"fromUOMId": "string",
"quantity": 0,
"toUOMId": "string"
}
}
}
EOF
Variables:
{
"data": {
"fromUOMId": "string",
"quantity": 0,
"toUOMId": "string"
}
}
Response:
{
"data": {
"convertQuantity": {
"conversionFactor": 0,
"convertedQuantity": 0,
"formatted": "string",
"fromUOM": {
"id": "id",
"code": "string",
"colorCode": "string",
"name": "string",
"pluralName": "string",
"createdAt": "2025-01-15T00:00:00Z"
}
}
}
}
convertQuantity(
data: ConvertQuantityInput!
): ConvertQuantityResult!
Arguments
convertQuantity.data ● ConvertQuantityInput! non-null input
The quantity and the units to convert between.
Type
ConvertQuantityResult object
The converted quantity and the factor used.