hasura/graphql-engine · error · OrderByExpressionError
The type of the order by expression {order_by_expression_nam
Error message
The type of the order by expression {order_by_expression_name} referenced in field {field_name} does not match the field type. Order by expression type: {order_by_expression_type}; field type: {field_type}. What it means
The type produced by the order-by expression does not match the type of the field that references it. The message prints both the expression's type and the field's (qualified base) type; they must agree for ordering to type-check.
Source
Thrown at v3/crates/metadata-resolve/src/stages/order_by_expressions/error.rs:57
#[error(
"Invalid orderable field {field_name}. Exactly one of `enable_order_by_directions` or `order_by_expression_name` must be specified."
)]
InvalidOrderByExpressionOrderableField { field_name: FieldName },
#[error(
"The order by expression {order_by_expression_name} referenced in field {field_name} has not been defined"
)]
UnknownOrderByExpressionNameInOrderableField {
order_by_expression_name: OrderByExpressionName,
field_name: FieldName,
},
#[error(
"The order by expression {order_by_expression_name} referenced in orderable relationship {relationship_name} has not been defined"
)]
UnknownOrderByExpressionNameInOrderableRelationship {
order_by_expression_name: OrderByExpressionName,
relationship_name: RelationshipName,
},
#[error(
"The type of the order by expression {order_by_expression_name} referenced in field {field_name} does not match the field type. Order by expression type: {order_by_expression_type}; field type: {field_type}. "
)]
OrderableFieldTypeError {
order_by_expression_name: OrderByExpressionName,
order_by_expression_type: TypeName,
field_type: QualifiedBaseType,
field_name: FieldName,
},
#[error("{0}")]
GraphqlConfigError(#[from] graphql_config::GraphqlConfigError),
#[error("{message}")]
UnsupportedFeature { message: String },
}
#[derive(Debug, thiserror::Error)]
#[allow(clippy::enum_variant_names)]
pub enum OrderableRelationshipError {
#[error(View on GitHub (pinned to 724551b9ae)
Solutions
- Align the expression's output type with the field's declared type (cast inside the expression or adjust the expression)
- Re-check the field's type mapping if it recently changed
- If the expression intentionally orders differently, give the field a matching type or use a dedicated expression/field pair
Defensive patterns
Strategy: validation
Validate before calling
// Ensure expression output type equals the field's type
const exprType = resolveExpressionType(orderByExpressions[name]);
if (!typeNameEquals(exprType, fieldBaseType(field.type))) throw new Error(`Type mismatch for order-by expression ${name}`); Prevention
- Write expressions against the same column they order
- Re-validate expressions after changing a field's declared type
When it happens
Trigger: An order_by_expression returns e.g. a computed String while the field is typed as a timestamp scalar, or the expression was written against a different column/type than the field it is attached to.
Common situations: Expressions returning a coerced/cast value differing from the column type; changing a field's type without updating its expression; connector type mapping differences making resolved types diverge.
Related errors
- Column order by target path did not end in a column field va
- the type of the comparable field '{field_name}' ({field_type
- The field {field_name:} has type {field_type:} but the field
- the aggregate expression '{aggregate_expression}' is used wi
- the field {field_name:} in {type_name:} should have the type
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/9409607d412a3b50.
Report an issue: GitHub.