hasura/graphql-engine · error · TypePredicateError
The model '{target_model_name:}' corresponding to the relat
Error message
The model '{target_model_name:}' corresponding to the relationship '{relationship_name:}' used in predicate for type '{type_name:}' is not defined What it means
A relationship used inside a type predicate points to a target model that is not defined in the resolved metadata. The resolver must load the target model to translate the relationship predicate; if `target_model_name` doesn't resolve, it fails with this error.
Source
Thrown at v3/crates/metadata-resolve/src/types/error.rs:496
NoBooleanExpressionFields {
field_name: Spanned<FieldName>,
type_name: Qualified<CustomTypeName>,
},
#[error(
"relationship '{relationship_name}' is used in predicate but does not exist for type '{type_name}'"
)]
UnknownRelationshipInTypePredicate {
relationship_name: Spanned<RelationshipName>,
type_name: Qualified<CustomTypeName>,
},
#[error(
"relationship '{relationship_name}' is used in predicate but does not exist in comparableRelationships in boolean expression '{boolean_expression_type_name}'"
)]
RelationshipNotComparableInTypePredicate {
relationship_name: Spanned<RelationshipName>,
boolean_expression_type_name: Qualified<CustomTypeName>,
},
#[error(
"The model '{target_model_name:}' corresponding to the relationship '{relationship_name:}' used in predicate for type '{type_name:}' is not defined"
)]
UnknownModelUsedInRelationshipTypePredicate {
type_name: Qualified<CustomTypeName>,
target_model_name: Qualified<ModelName>,
relationship_name: RelationshipName,
},
#[error(
"target source for model '{target_model_name:}' is required to resolve predicate with relationships for {source_type_name:}"
)]
TargetSourceRequiredForRelationshipPredicate {
source_type_name: Qualified<CustomTypeName>,
target_model_name: Qualified<ModelName>,
},
#[error("{error:} in type {type_name:}")]
TypeMappingCollectionError {
type_name: Qualified<CustomTypeName>,
error: TypeMappingCollectionError,View on GitHub (pinned to 724551b9ae)
Solutions
- Search metadata for `target_model_name` — confirm a model with that qualified name exists
- Fix the relationship's target model reference (name or subgraph prefix), or restore/re-declare the model
- Ensure the subgraph containing the target model is included in the build/link graph
Example fix
# before
relationships:
- name: articles
targetModel: article # model is named 'articles' elsewhere
# after
relationships:
- name: articles
targetModel: articles
Defensive patterns
Strategy: validation
Validate before calling
// Ensure the relationship's target model exists before resolving predicates
if !metadata.models.contains_key(&relationship.target_model) {
return Err(format!("target model {} undefined", relationship.target_model));
} Type guard
fn target_model_exists<'a>(md: &'a Metadata, m: &Qualified<ModelName>) -> Option<&'a Model> {
md.models.get(m)
} Try / catch
if let Err(TypePredicateError::UnknownModelUsedInRelationshipTypePredicate { target_model_name, .. }) = result {
return Err(format!("define or fix reference to model {target_model_name}"));
} Prevention
- Delete/update all relationship references when removing or renaming models
- Validate cross-model references in CI metadata checks
When it happens
Trigger: Relationship predicate referencing a model that was deleted, renamed, or lives in a subgraph not being resolved; qualified model-name prefix mismatch; typo in the relationship's target model.
Common situations: Renaming/removing models without updating relationships that point at them; multi-subgraph setups where the target model is in another subgraph that isn't linked; metadata file for the target model not included in the build.
Related errors
- Target model {model_name:} not found, referenced in relation
- relationship '{relationship_name}' is used in predicate but
- target source for model '{target_model_name:}' is required t
- the comparable relationship '{relationship_name}' for the op
- the target model '{target_model_name}' of the relationship '
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/ac51a2a493f76c8e.
Report an issue: GitHub.