hasura/graphql-engine · error · TypePredicateError

field '{field_name:}' used in predicate for type '{type_name

Error message

field '{field_name:}' used in predicate for type '{type_name:}' could not be found in boolean expression {boolean_expression_type}

What it means

A type predicate referenced a field that the resolver could not find in the corresponding boolean expression type (the generated filter input type). Even though the field may exist on the object type, the boolean expression type built for it does not contain that field, so filtering on it is impossible.

Source

Thrown at v3/crates/metadata-resolve/src/types/error.rs:392

        for (index, elem) in self.lines_of.iter().enumerate() {
            elem.fmt(f)?;
            if index < self.lines_of.len() - 1 {
                writeln!(f)?;
            }
        }

        Ok(())
    }
}

#[derive(Debug, thiserror::Error)]
pub enum TypePredicateError {
    #[error("unknown field '{field_name:}' used in predicate for type '{type_name:}'")]
    UnknownFieldInTypePredicate {
        field_name: Spanned<FieldName>,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "field '{field_name:}' used in predicate for type '{type_name:}' could not be found in boolean expression {boolean_expression_type}"
    )]
    TypePredicateFieldNotFoundInBooleanExpression {
        field_name: Spanned<FieldName>,
        type_name: Qualified<CustomTypeName>,
        boolean_expression_type: Qualified<CustomTypeName>,
    },

    #[error("field '{field_name:}' could not be found in field mappings for type '{type_name:}'")]
    UnknownFieldInFieldMappings {
        field_name: Spanned<FieldName>,
        type_name: Qualified<CustomTypeName>,
    },
    #[error(
        "field '{field_name:}' of type '{type_name:}' is an array type and cannot be used in a nested field predicate"
    )]
    ArrayFieldInNestedFieldPredicate {
        field_name: Spanned<FieldName>,

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Compare the fields of `boolean_expression_type` (named in the message) against the field you're filtering on
  2. Add the missing field to the boolean expression type / make the field filterable in metadata
  3. Filter on a different field that IS in the boolean expression type
  4. If using a custom filterExpressionType, regenerate or update it to include the field

Example fix

# before: boolean expression type lacks 'email' but predicate filters on it
{"field": "email", "operator": "_eq", "value": "a@b.c"}
# after: add email to the boolean expression type, or filter an included field
{"field": "id", "operator": "_eq", "value": "123"}
Defensive patterns

Strategy: validation

Validate before calling

// Verify the field is present in the boolean expression type before filtering
let ok = bool_expr_type
    .data_fields
    .keys()
    .any(|f| f.as_str() == target_field);
if !ok { return Err("field not in boolean expression type".into()); }

Type guard

fn field_in_expr(expr: &BooleanExpressionType, name: &str) -> bool {
    expr.data_fields.keys().any(|f| f.as_str() == name)
}

Try / catch

if let Err(TypePredicateError::TypePredicateFieldNotFoundInBooleanExpression { field_name, boolean_expression_type, .. }) = result {
    // hint: update the expression type or pick another field
}

Prevention

When it happens

Trigger: Using a field in a `filterExpressionType` predicate whose boolean expression type doesn't include it (e.g. the field was excluded from filterable fields, or a custom boolean expression type was provided that omits it); referencing an aggregate/computed field not present in the boolean expression input.

Common situations: Custom boolean expression types that don't mirror all fields of the object type; fields explicitly made non-filterable; version changes that alter which fields get into the boolean expression type.

Related errors


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