hasura/graphql-engine · error · TypeError::TypeCheckError
type mismatch
Error message
type mismatch: {error:} What it means
A TypeError wrapper indicating that a value expression failed type checking: the expression's inferred type did not match the type expected by its context (argument, field, comparison, etc.). The underlying TypecheckError carries specifics of the mismatch (e.g. string vs uuid).
Solutions
- Read the inner TypecheckError message for expected vs actual types
- Fix the expression (literal, preset, or variable) so its type matches the declared argument/field type
- If a session variable is involved, remember it is a string; cast or compare accordingly
Example fix
// before
preset: "2023-01-01" // declared as date comparison
// after
preset: { eq: "2023-01-01" } // matches the comparison type Defensive patterns
Strategy: validation
Validate before calling
// Validate expression types against the declared argument type before submission assert_expression_type_matches(&expr, &declared_type)?;
Try / catch
match result {
Err(Error::TypeError(TypeError::TypeCheckError { error })) => {
eprintln!("type mismatch: {error}");
}
_ => {}
} Prevention
- Keep argument types and presets in one review when changing schemas
- Add unit tests covering each preset expression
When it happens
Trigger: Any metadata resolution path that runs the typechecker on expressions, e.g. argument presets, command arguments, or filter expressions where the expression type (literal, variable, session variable) does not unify with the declared target type (TypeCheckError { error: TypecheckError }).
Common situations: Passing a string literal or session variable where a uuid/date/comparison type is declared; boolean expressions used where a scalar is expected; mismatches after changing a field's type without updating presets.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- {0}
- {0}
- a source must be defined for model
- An issue occurred while mapping arguments in the model
- 'apolloFederation.keys' for type
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/4314aa3d6cc99c2b.
Report an issue: GitHub.
Appendix: source
Thrown at v3/crates/metadata-resolve/src/types/error.rs:715
path: field_name.path.clone(),
subgraph: field_type.get_subgraph().cloned(),
}
))
}
TypePredicateError::ScalarBooleanExpressionTypeError(error) => error.create_error_context(),
_ => None
}
}
}
#[derive(Debug, thiserror::Error)]
pub enum TypeError {
#[error("expected to find a custom named type in {qualified_type_reference:} but none found")]
NoNamedTypeFound {
qualified_type_reference: QualifiedTypeReference,
},
#[error("type mismatch: {error:}")]
TypeCheckError { error: TypecheckError },
}
impl From<AggregateExpressionError> for Error {
fn from(val: AggregateExpressionError) -> Self {
Error::AggregateExpressionError(val)
}
}
impl From<TypecheckError> for Error {
fn from(type_error: TypecheckError) -> Self {
Error::TypeError {
type_error: TypeError::TypeCheckError { error: type_error },
}
}
}
View on GitHub (pinned to 724551b9ae)