hasura/graphql-engine · error · ModelsIssue

The target model '{target_model_name}' of the orderable rela

Error message

The target model '{target_model_name}' of the orderable relationship '{relationship_name}' in order by expression '{order_by_expression_identifier}' used in model '{model_name}' must have a source

What it means

An order_by_expression traverses an orderable relationship whose target model has no source (no data connector backing), which is required to resolve ordering.

Source

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

    },
    #[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}"
    )]
    OrderableRelationshipError {
        order_by_expression_identifier: Qualified<OrderByExpressionIdentifier>,
        model_name: Qualified<ModelName>,
        error: order_by_expressions::OrderableRelationshipError,
    },
    #[error(
        "The target model '{target_model_name}' of the orderable relationship '{relationship_name}' in order by expression '{order_by_expression_identifier}' used in model '{model_name}' must have a source"
    )]
    OrderableRelationshipTargetModelMustHaveASource {
        order_by_expression_identifier: Qualified<OrderByExpressionIdentifier>,
        model_name: Qualified<ModelName>,
        relationship_name: open_dds::relationships::RelationshipName,
        target_model_name: Qualified<ModelName>,
    },
    #[error(
        "The target command '{target_command_name}' of the orderable relationship '{relationship_name}' in order by expression '{order_by_expression_identifier}' used in model '{model_name}' must have a source"
    )]
    OrderableRelationshipTargetCommandMustHaveASource {
        order_by_expression_identifier: Qualified<OrderByExpressionIdentifier>,
        model_name: Qualified<ModelName>,
        relationship_name: open_dds::relationships::RelationshipName,
        target_command_name: Qualified<CommandName>,
    },
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Add a source (data connector collection or command) to the target model
  2. Point the relationship at a model that has a source
  3. Remove the order_by_expression that traverses this relationship
Defensive patterns

Strategy: validation

Validate before calling

// every orderable-relationship target model must have a source
for rel in &type.relationships {
    if rel.orderable {
        assert!(models[&rel.target_model].source.is_some(), "target model {} has no source", rel.target_model);
    }
}

Prevention

When it happens

Trigger: Defining an order_by_expression over a relationship pointing at a model with no source configured (only a type, no underlying collection/command).

Common situations: Adding relationship-based ordering to models whose target is a placeholder/unsourced model; incomplete metadata where the target model's source wasn't defined yet.

Related errors


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