I am having this problem when using the CQRS module. Essentially, it keeps saying it cannot find my query (and command) handlers. Here's my setup.
In my controller, I have this.
@Controller('accounts')
export class AccountsController {
constructor(
private readonly commandBus: CommandBus,
private readonly queryBus: QueryBus,
private readonly logger: SystemLogger,
) {
}
// ....
async onApplicationBootstrap() {
// ...
const account: Account | null = await this.queryBus.execute(
new GetRootAccountQuery(correlation)
);
// ...
}
What is supposed to happen is that on startup, my app first checks if a root account exists (indicating the application has been set up). If there isn't it creates one.
My module is set up as follows.
const commandHandlers = [
CreateAccountHandler,
CreateRootAccountHandler
];
const queryHandlers = [
GetAccountForIdQuery,
GetAccountForIdHandler,
GetRootAccountQuery,
GetRootAccountHadler,
GetAccountIdentifierQuery,
GetAccountIdentifierHandler,
GetAccountForEmailQuery,
GetAccountForEmailHandler
];
const sagas = [AccountsSagas];
const eventHandlers = [
CreateAccountSummaryHandler
]
@Module({
controllers: [AccountsController],
providers: [
FireStoreAccountsEventStore,
...commandHandlers,
...queryHandlers,
...sagas,
...eventHandlers
],
imports: [
CqrsModule,
CoreModule,
ConfigModule
],
exports: [
GetAccountForIdQuery,
GetAccountIdentifierQuery,
GetAccountForEmailQuery
]
})
export class AccountsModule {}
I double checked the docs to make sure I was doing everything correctly. However, when I start the application, it is saying it cannot find the query handler (and the event handler when I comment out the above code and force it to run the command to create the root account). My logs are telling me that it isn't even entering the handler class for the query.
What am I doing wrong?