{"record":{"id":"a9594af3d8c2fa4d","repo":"hasura/graphql-engine","slug":"relationship-relationship-name-is-used-in-pred","errorCode":null,"errorMessage":"relationship '{relationship_name}' is used in predicate but does not exist for type '{type_name}'","messagePattern":"relationship '(.+?)' is used in predicate but does not exist for type '(.+?)'","errorType":"validation","errorClass":"TypePredicateError","httpStatus":null,"severity":"error","filePath":"v3/crates/metadata-resolve/src/types/error.rs","lineNumber":482,"sourceCode":"    },\n\n    #[error(\"Invalid operator used in type '{type_name:}' predicate: '{operator_name:}'\")]\n    InvalidOperatorInTypePredicate {\n        type_name: Qualified<CustomTypeName>,\n        operator_name: Spanned<OperatorName>,\n    },\n    #[error(\"Nested predicate used in type '{type_name:}'\")]\n    NestedPredicateInTypePredicate {\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"no boolean expression found for type '{type_name:}' This is required when filtering a nested field. Please ensure the model you are filtering has a filterExpressionType defined.\"\n    )]\n    NoBooleanExpressionFields {\n        field_name: Spanned<FieldName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"relationship '{relationship_name}' is used in predicate but does not exist for type '{type_name}'\"\n    )]\n    UnknownRelationshipInTypePredicate {\n        relationship_name: Spanned<RelationshipName>,\n        type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"relationship '{relationship_name}' is used in predicate but does not exist in comparableRelationships in boolean expression '{boolean_expression_type_name}'\"\n    )]\n    RelationshipNotComparableInTypePredicate {\n        relationship_name: Spanned<RelationshipName>,\n        boolean_expression_type_name: Qualified<CustomTypeName>,\n    },\n    #[error(\n        \"The model '{target_model_name:}' corresponding to the  relationship '{relationship_name:}' used in predicate for type '{type_name:}' is not defined\"\n    )]\n    UnknownModelUsedInRelationshipTypePredicate {\n        type_name: Qualified<CustomTypeName>,","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/metadata-resolve/src/types/error.rs#L464-L500","documentation":"A predicate references a relationship by name, but the type being filtered has no relationship with that name. The resolver validates relationship references inside predicates against the type's declared relationships before using them.","triggerScenarios":"Filtering like `{relationship: <name>, ...}` where `<name>` is not declared under the type's relationships; renaming/removing a relationship without updating filters; typo in relationship name.","commonSituations":"Relationship renames during metadata refactoring; filters written against another model's relationships; namespaced relationship names (qualified names) referenced unqualified.","solutions":["Check `relationship_name` in the message against the relationships declared on `type_name`","Fix the name, or declare the missing relationship on the type","If the relationship was removed intentionally, drop the predicate that uses it"],"exampleFix":"# before\nrelationships:\n  - name: authoredPosts\n# filter uses {relationship: posts, ...} -> error\n# after: use the declared name\n{relationship: authoredPosts, ...}\n","handlingStrategy":"validation","validationCode":"// Verify the relationship exists on the type before using it in a predicate\nif !object_type.relationships.contains_key(&relationship_name) {\n    return Err(format!(\"relationship {relationship_name} not on type\"));\n}","typeGuard":"fn relationship_exists(t: &ObjectType, r: &RelationshipName) -> bool {\n    t.relationships.contains_key(r)\n}","tryCatchPattern":"if let Err(TypePredicateError::UnknownRelationshipInTypePredicate { relationship_name, type_name }) = result {\n    return Err(format!(\"{relationship_name} not declared on {type_name}\"));\n}","preventionTips":["Keep filter definitions next to relationship declarations in metadata","Grep for relationship usages when renaming relationships"],"tags":["relationship","predicate","filter","metadata","hasura"],"backgroundTag":"relationship-not-found","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}