hasura/graphql-engine · error · BooleanExpressionError::TargetModelNotFound
Target model {model_name:} not found, referenced in relation
Error message
Target model {model_name:} not found, referenced in relationship {relationship_name:} What it means
A relationship references a target model that does not exist in the resolved metadata. Relationship resolution happens during boolean expression type resolution, and the target model lookup fails.
Source
Thrown at v3/crates/metadata-resolve/src/stages/boolean_expressions/error.rs:163
DataConnectorScalarRepresentationsNotFound {
data_connector_name: Qualified<DataConnectorName>,
boolean_expression_type: Qualified<CustomTypeName>,
},
#[error(
"Field level comparison operator configuration is not fully supported yet. Please use \"enableAll\":true."
)]
FieldLevelComparisonOperatorConfigurationNotSupported,
#[error(
"Field level comparison operator configuration is not fully supported yet. Please add all fields in filterable_fields."
)]
FieldLevelComparisonOperatorNeedsAllFields,
#[error("a source must be defined for model {model:} in order to use filter expressions")]
CannotUseFilterExpressionsWithoutSource { model: Qualified<ModelName> },
#[error(
"Target model {model_name:} not found, referenced in relationship {relationship_name:}"
)]
TargetModelNotFound {
relationship_name: RelationshipName,
model_name: Qualified<ModelName>,
},
#[error(
"Model {model:} has source data connector {model_data_connector:} but its filter expression type {filter_expression_type:} is backed by data connector {filter_expression_data_connector:}"
)]
DifferentDataConnectorInFilterExpression {
model: Qualified<ModelName>,
model_data_connector: Qualified<DataConnectorName>,
filter_expression_type: Qualified<CustomTypeName>,
filter_expression_data_connector: Qualified<DataConnectorName>,
},
#[error(
"Model {model:} has source data connector object type {model_data_connector_object_type:} but its filter expression type {filter_expression_type:} is backed by data connector {filter_expression_data_connector_object_type:}"View on GitHub (pinned to 724551b9ae)
Solutions
- Fix the target model name in the relationship to the exact Qualified<ModelName> (including namespace)
- Create the missing target model if it should exist
- Ensure the directory containing the target model's metadata is included in the metadata sources
Example fix
// before
relationships:
albums:
targetModel: Album
// after
relationships:
albums:
targetModel:
name: Album
subgraph: music Defensive patterns
Strategy: validation
Validate before calling
const modelNames = new Set(models.map(m => qualifiedName(m)));
for (const rel of relationships) {
if (!modelNames.has(qualifiedName(rel.targetModel))) {
fail(`relationship ${rel.name} targets unknown model ${rel.targetModel}`);
}
} Prevention
- Always fully qualify target model names (name + subgraph)
- When renaming/deleting a model, grep relationships for references
- Keep all related metadata in the same build so resolution sees the target
When it happens
Trigger: Declaring a relationship whose targetModelName refers to a model that is not defined (or not yet resolved) in the metadata; typo in the target model name; different subgraph/namespace qualification.
Common situations: Renaming or deleting a model without updating relationships pointing at it; cross-namespace reference missing the fully qualified name; a model in another OpenDDs directory not included in the build.
Related errors
- The model '{target_model_name:}' corresponding to the relat
- the comparable relationship '{relationship_name}' for the op
- the target model '{target_model_name}' of the relationship '
- unknown field '{field_name}' for type '{type_name}' used in
- relationship '{relationship_name}' is used in predicate but
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/eeb9420a5e45a0af.
Report an issue: GitHub.