hasura/graphql-engine · error · AggregateBooleanExpressionError

type mismatch between the '{count_type}' aggregate (return t

Error message

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}')

What it means

Similar to the general aggregation-function mismatch, this variant applies to the built-in count aggregates: the resolved return type of the count aggregate must equal the operand type of the boolean expression type used in the comparison. Count aggregates can be typed differently (e.g. Int vs BigInt vs custom count types), and a mismatch triggers this error.

Source

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

    },

    #[error(
        "the aggregation function '{aggregation_function_name}' returns an array type ({aggregation_function_return_type}). Array types are not supported in aggregate comparisons"
    )]
    ComparisonAgainstArrayTypesNotSupported {
        aggregation_function_name: AggregationFunctionName,
        aggregation_function_return_type: QualifiedTypeReference,
    },

    #[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,
    },

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Use a boolean expression type whose operand type matches the count aggregate's declared return type
  2. Align the connector's count scalar type with what metadata expects (or regenerate the metadata)
  3. If types are meant to be the same, fix scalar type mappings so the qualified type names match

Example fix

// before
filter: { count: { _gt: 10 } } // count returns BigInt, bool exp operand Int

// after
filter: { count: { _gt: 10 } } // use BigInt-typed bool exp / aligned scalar
Defensive patterns

Strategy: validation

Validate before calling

assert_eq!(count_agg.return_type.qualified_name(), bool_exp.operand_type.qualified_name(),
    "count aggregate / boolean expression type mismatch");

Type guard

fn count_type_matches(ret: &QualifiedTypeName, operand: &QualifiedTypeName) -> bool {
    ret == operand
}

Try / catch

match resolve(expr) {
    Err(ResolveError::CountAggregateTypeMismatch { count_type, .. }) => {
        // select a bool exp typed for the count's scalar (e.g. BigInt) and retry
    }
    r => r,
}

Prevention

When it happens

Trigger: Comparing a count aggregate whose return type is a custom/BigInt scalar against a boolean expression type whose operand is a different scalar (e.g. Int); changing the configured count return type in connector capabilities without regenerating dependent boolean expression types.

Common situations: Connectors defining custom count scalar types (e.g. BigInt) while metadata compares using Int-typed expressions; upgrading a connector that changes the count aggregate's scalar type; mixing hand-written and generated metadata.

Related errors


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