hasura/graphql-engine · error · ModelsIssue

The orderable field '{field_name}' in model '{model_name}' i

Error message

The orderable field '{field_name}' in model '{model_name}' is an array type (type: {field_type}) and therefore cannot be used for ordering

What it means

An orderable field in a v1 model has an array type, and array fields cannot be used for ordering.

Source

Thrown at v3/crates/metadata-resolve/src/stages/models/types.rs:116

pub enum ModelsIssue {
    #[error(
        "An issue occurred while mapping arguments in the model {model_name:} to the collection {collection_name:} in the data connector {data_connector_name:}: {issue:}"
    )]
    FunctionArgumentMappingIssue {
        data_connector_name: Qualified<DataConnectorName>,
        model_name: Qualified<ModelName>,
        collection_name: CollectionName,
        issue: ArgumentMappingIssue,
    },
    #[error(
        "The orderable field '{field_name}' in model '{model_name}' is not a scalar field (type: {field_type}) and therefore cannot be used for ordering. Upgrade to version 2 Models and use OrderByExpressions to order by nested fields"
    )]
    ModelV1OrderableFieldIsNotAScalarField {
        model_name: Qualified<ModelName>,
        field_name: FieldName,
        field_type: QualifiedTypeReference,
    },
    #[error(
        "The orderable field '{field_name}' in model '{model_name}' is an array type (type: {field_type}) and therefore cannot be used for ordering"
    )]
    ModelV1OrderableFieldIsAnArrayType {
        model_name: Qualified<ModelName>,
        field_name: FieldName,
        field_type: QualifiedTypeReference,
    },
    #[error(
        "The order by expression '{order_by_expression_identifier}' used in model '{model_name}' contains a nested field '{nested_field_name}', however the data connector '{data_connector_name}' used in the model does not support ordering by nested fields"
    )]
    OrderByExpressionContainsUnsupportedNestedField {
        order_by_expression_identifier: Qualified<OrderByExpressionIdentifier>,
        model_name: Qualified<ModelName>,
        nested_field_name: FieldName,
        data_connector_name: Qualified<DataConnectorName>,
    },
    #[error(
        "Issue in order by expression '{order_by_expression_identifier}' used by model '{model_name}': {error}"

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Remove the array field from orderable_fields
  2. Order by a scalar field instead (e.g. array_length or a related scalar in v2)

Example fix

# before
orderable_fields:
  - field: tags   # array
# after
orderable_fields:
  - field: created_at
Defensive patterns

Strategy: validation

Validate before calling

// reject array-typed orderable fields before applying
for f in &model.orderable_fields {
    assert!(!is_array(&model.type_.fields[f]), "array field {} not orderable", f);
}

Type guard

const isArrayType = (t) => t.type.kind === 'array' || t.type.of?.kind === 'array';

Prevention

When it happens

Trigger: Listing an array/list-typed field (e.g. tags: [String]) in orderable_fields of a v1 model.

Common situations: Marking list columns as orderable in generated or hand-edited model metadata.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/80c7dc0d94a2a91c. Report an issue: GitHub.