ADocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Indroic/HexCore/llms.txt
Use this file to discover all available pages before exploring further.
Query represents a request for information — it has no side effects and changes no state. In CQRS, read operations are modelled separately from commands so that read paths can be optimised, cached, or served from read replicas independently of the write path. HexCore’s Query base class is a frozen Pydantic model that is generic over TResult, letting the type system verify that the query handler returns exactly the type the caller expects.
Class definition
Generic type parameter
The return type produced by the handler that processes this query. Declare it when subclassing
Query to propagate the expected return type all the way through the bus and handler interfaces.Query itself has no default fields. Unlike Command, it deliberately omits auto-generated IDs and timestamps because read operations are stateless and do not require audit trail metadata.Model configuration
| Option | Value | Effect |
|---|---|---|
frozen | True | Query objects are immutable and hashable after construction, preventing accidental mutation in middleware. |
from_attributes | True | Allows constructing a query from attribute-bearing objects (ORM rows, dataclasses) via Query.model_validate(obj). |
Type aliases
Unconstrained type variable representing the result a query handler will return. Parameterise your
Query subclass with this to propagate static type information through buses and handlers.A type variable bound to
Query[Any]. Used in AbstractQueryHandler to constrain which query type a handler accepts.