hasura/graphql-engine · error · AggregateBooleanExpressionError

the operand type '{operand_type}' does not match the operand

Error message

the operand type '{operand_type}' does not match the operand type of the filter boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'

What it means

Aggregate filters can themselves have filter inputs; this error fires when the operand type of the nested filter expression does not match the operand type that the referenced boolean expression type declares. The resolver compares the qualified operand type of the filter input against the boolean expression type's operand type and requires an exact match.

Source

Thrown at v3/crates/metadata-resolve/src/stages/aggregate_boolean_expressions/types.rs:219

    #[error(
        "the {count_type} aggregation cannot be compared to because it is not enabled on the aggregate expression '{aggregate_expression}'"
    )]
    CountAggregateNotEnabled {
        count_type: CountAggregateType,
        aggregate_expression: Qualified<AggregateExpressionName>,
    },

    #[error(
        "type mismatch between the '{count_type}' aggregate (return type: '{count_return_type}') and the specified boolean expression type '{boolean_expression_type}' (operand type: '{boolean_expression_operand_type}')"
    )]
    CountAggregateTypeMismatch {
        count_type: CountAggregateType,
        count_return_type: QualifiedTypeName,
        boolean_expression_type: BooleanExpressionTypeIdentifier,
        boolean_expression_operand_type: QualifiedTypeName,
    },

    #[error(
        "the operand type '{operand_type}' does not match the operand type of the filter boolean expression type '{boolean_expression_type}': '{boolean_expression_operand_type}'"
    )]
    FilterInputFilterExpressionTypeMismatch {
        operand_type: QualifiedTypeName,
        boolean_expression_type: Qualified<CustomTypeName>,
        boolean_expression_operand_type: QualifiedTypeName,
    },

    #[error("the order by expression '{order_by_expression}' could not be found")]
    OrderByExpressionNotFound {
        order_by_expression: Qualified<OrderByExpressionName>,
    },

    #[error("the field '{field_name}' is defined more than once in the comparable fields")]
    DuplicateComparableFieldsFound { field_name: FieldName },

    #[error(
        "the field '{field_name}' used in comparable fields is not an aggregatable field defined in the aggregate expression '{aggregate_expression}'"

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Verify the boolean expression type used in the filter is defined for the operand type being filtered
  2. Fix the relationship or target type so the filter's operand type matches the boolean expression type
  3. Regenerate or update metadata after changing object type mappings

Example fix

// before
where: { myFilter: { name: { _eq: "x" } } } // myFilter operand is TypeB, input is TypeA

// after
where: { typeAFilter: { name: { _eq: "x" } } } // operand matches
Defensive patterns

Strategy: type-guard

Validate before calling

assert_eq!(filter_input.operand_type.qualified_name(),
    bool_exp.operand_type.qualified_name(), "filter operand mismatch");

Type guard

fn filter_operand_matches(filter: &FilterInput, be: &BooleanExpressionType) -> bool {
    filter.operand_type == be.operand_type
}

Try / catch

match resolve(expr) {
    Err(ResolveError::FilterInputFilterExpressionTypeMismatch { boolean_expression_type, .. }) => {
        // use the bool exp defined on the actual operand type
    }
    r => r,
}

Prevention

When it happens

Trigger: Passing a filter input to an aggregate expression where the filter's operand type differs from the boolean_expression_type's operand type, e.g. filtering a relationship whose target type differs from the boolean expression type's operand type.

Common situations: Applying a relationship filter boolean expression to the wrong relationship/target type; remapping object types or relationships in metadata so operand types no longer line up; copy-pasting filter expressions between types with same-named but differently-typed fields.

Related errors


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