Skip to content

Conversation

JoshVee
Copy link

@JoshVee JoshVee commented Aug 20, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Currently, all @QueryHandler and @CommandHandler implementations need to be class providers.
If a factory provider is used, a TypeError is thrown when trying to reflect the command \ query metadata, eg:

TypeError
    at Reflect.getMetadata (/Users/work/code/apps/node_modules/reflect-metadata/Reflect.js:367:23)
    at QueryBus.reflectQueryId (/Users/work/code/apps/node_modules/@nestjs/cqrs/dist/query-bus.js:114:39)

What is the new behavior?

This PR modifies the InstanceWrapper reflection code within CommandBus and QueryBus to support factory providers.

The implementation reflects that used in EventBus.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@JoshVee JoshVee changed the title feat: add support for using factory providers for handlers feat: add support for using factory providers for QueryHandler and CommandHandler Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant