-
Notifications
You must be signed in to change notification settings - Fork 349
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
fix: only return Observable types for NestJS if the option is switched on #823
base: main
Are you sure you want to change the base?
Conversation
Bump on this, using nestJS currently doesn't allow me to generate methods returning a promise |
@tmthecoder if you've got |
@alexkb I see the types be promise or observable for the controller implementations but the clients only have observable in the definitions, not sure why that is. I have the observable flag set to false manually in the proto gen command |
|
||
findManyVillain(request: Observable<VillainById>): Observable<Villain>; | ||
|
||
findManyVillainStreamIn(request: Observable<VillainById>): Promise<Villain> | Observable<Villain> | Villain; | ||
findManyVillainStreamIn(request: Observable<VillainById>): Promise<Villain> | Villain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexkb Disclaimer that I don't use NestJS, but wouldn't just Promise<Villain>
make more sense here as a return type?
I agree that your PR is already better than the previous Observable<T> | Promise<T> | T
, which imo seems just kind of maddening to use as a caller, b/c you'd have to constantly be checking what the return value was.
...ah, maybe this interface is meant for the server-side to implement, and we want to give flexibility to the server to return what it wants.
Are these interfaces used by both the client and the server? I don't remember...
We're using
--ts_proto_opt=nestjs=true
and wanted to removeObservable
's being returned, so we tried--ts_proto_opt=returnObservable=false
but it had no effect.This PR fixes that issue so it does behave as expected. If it is incorrect, then I suggest you update the documentation to make it clear that
returnObservable
has no effect whennestjs=true
. Thanks.