Skip to main content

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:

query ConvertQuantity($data: ConvertQuantityInput!) {
convertQuantity(data: $data) {
conversionFactor
convertedQuantity
formatted
fromUOM {
id
code
colorCode
name
pluralName
createdAt
}
}
}

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.