hasura/graphql-engine · error · AggregateBooleanExpressionError

boolean expressions with aggregate operands are not supporte

Error message

boolean expressions with aggregate operands are not supported

What it means

AggregateBooleanExpressionError::AggregateBooleanExpressionsNotSupported is returned when a boolean expression is defined with aggregate operands in a context where aggregate operands are not supported (the variant exists to explicitly reject such definitions during resolution).

Source

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

    pub type_name: ast::TypeName,
}

#[derive(Debug, thiserror::Error)]
#[error("error in boolean expression type '{type_name}': {error}")]
pub struct NamedAggregateBooleanExpressionError {
    pub type_name: Qualified<CustomTypeName>,
    pub error: AggregateBooleanExpressionError,
}

impl ContextualError for NamedAggregateBooleanExpressionError {
    fn create_error_context(&self) -> Option<error_context::Context> {
        None
    }
}

#[derive(Debug, thiserror::Error)]
pub enum AggregateBooleanExpressionError {
    #[error("boolean expressions with aggregate operands are not supported")]
    AggregateBooleanExpressionsNotSupported,

    #[error("boolean expressions with aggregate operands do not support isNull comparisons")]
    IsNullComparisonsNotSupported,

    #[error("{0}")]
    GraphqlConfigError(#[from] GraphqlConfigError),

    #[error("the operand type '{operand_type}' must be a scalar type")]
    OperandTypeIsNotAScalarType {
        operand_type: Qualified<CustomTypeName>,
    },

    #[error("the operand type '{operand_type}' must be an object type")]
    OperandTypeIsNotAnObjectType {
        operand_type: Qualified<CustomTypeName>,
    },

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Remove the aggregate operands from the boolean expression definition
  2. Redesign the operation to compute the aggregate separately and filter on the result, rather than inside the boolean expression
  3. Check the docs for where aggregate boolean expressions are permitted

Example fix

# before
boolean_expression:
  operands:
    - aggregate: count   # not supported here

# after
boolean_expression:
  operands:
    - field: status
Defensive patterns

Strategy: validation

Validate before calling

fn uses_aggregate_operands(expr: &BooleanExpressionDef) -> bool {
    expr.operands.iter().any(|o| o.aggregate.is_some())
}
// reject before submission in contexts where aggregates are disallowed

Try / catch

if let AggregateBooleanExpressionError::AggregateBooleanExpressionsNotSupported = err {
    eprintln!("aggregate operands are not allowed here; use plain field comparisons");
}

Prevention

When it happens

Trigger: Defining a boolean expression type whose operands involve aggregate expressions in a metadata context that does not allow them (e.g. using an aggregate-capable filter where only scalar/object comparisons are valid).

Common situations: Attempting to filter on aggregated values in places where only row-level comparisons apply; version changes that tightened restrictions on aggregate boolean expressions.

Related errors


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