grpc loader.defauts does not work to control the response value
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 716
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 10
Description
### Current behavior
we want to get such response from grpc api
```
{
"code": 0,
"statusCode": 1,
"data": {
"nullValue": null,
"zeroValue": 0,
"message": "great"
}
}
```
so we overwrite the options.loader.defaults to get the zero value code item as follows:
```
app.connectMicroservice(
{
transport: Transport.GRPC,
options: {
url: '0.0.0.0:6000', // gRPC 服务的地址和端口
package: 'hello', // proto 文件中的 package 名称
protoPath: join(__dirname, '../proto/hello.proto'), // proto 文件路径
loader: {
defaults: true, // expected to get the zero value code in response
arrays: true,
objects: true,
json: true,
},
},
},
```
but we when I tested the result, I get confused because the result are not the same rule.
- with Postman we always get the zero value code in response whether loader.defaults is true
- with GRPC Client code we always get the zero value code in response whether loader.defaults is true
- with grpcurl we always cannot get the zero value code in response whether loader.defaults is true
- with Jetbrains HTTPClient we always cannot get the zero value code in response whether loader.defaults is true
### Minimum reproduction code
https://github.com/rawbin-/nest-grpc-test/tree/main/appx
### Steps to reproduce
```
pnpm i
pnpm start:dev
```
test with any grpc client tool
### Expected behavior
loader.defaults can control the result
### Packages versions
```json
"@grpc/grpc-js": "^1.13.3",
"@grpc/proto-loader": "^0.7.15",
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/microservices": "^11.1.0",
"@nestjs/platform-express": "^10.0.0",
"grpc": "^1.24.11",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
```
### Node.js version
v18.20.7
### In which operating systems have you tested?
- [x] macOS
- [ ] Windows
- [ ] Linux
Contributor guide
Assessment
This issue has not been assessed yet.