Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about return type in queryBus.execute #614

Closed
alexgev opened this issue Apr 1, 2021 · 2 comments
Closed

Question about return type in queryBus.execute #614

alexgev opened this issue Apr 1, 2021 · 2 comments

Comments

@alexgev
Copy link

alexgev commented Apr 1, 2021

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
[x] Question

Current behavior

Nest js knows about return type in queryBus.execute even though queries, controllers and services are independent of handlers and return type is TResult = any. But if i clone source code in my project, return type become any. How did you do it? Is this nest js container or what? Thank you for answer.

// return type is Promise<Hero[]>
this.queryBus.execute(new GetHeroesQuery());

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@kgajowy
Copy link

kgajowy commented Apr 27, 2021

@alexgev NestJS does not infer the return type based on Query, you would need to specify types while executeing. Similar issue raised there

we have released the package that may be useful to achieve the above:

https://github.com/valueadd-poland/nestjs-packages/tree/master/packages/typed-cqrs

@alexgev
Copy link
Author

alexgev commented Apr 27, 2021

Thank you!

@alexgev alexgev closed this as completed Apr 27, 2021
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

No branches or pull requests

2 participants