Comments (5)
However, back to the original topic, question is, actually, whether there is a real need in optional parameters at all.
Optional parameters is something related to the transport in the runtime, I guess. On the TypeScript side the optional parameters mean something entirely different. All the scalar values get their defaults anyway, in other words they can never be null / undefined. The only case where something can be optional is the non-repeated message field.
Maybe it makes more sense to just have none of the optional fields at all, but the messages, and then respect this new flag in order to make them non-optional?
from ngx-grpc.
Hi @johannesf95
nope, this old plugin generator is not anyhow something we should rely on. Of course it is better to migrate to one from google-protobuf.
I tried it so far, looks pretty good, the migration went quite quickly; looks like the old lib was sticking very close to the original protobuf messages.
Thank you very much for the time you took for the deep research!
from ngx-grpc.
Hi @smnbbrv, thanks for this fast reaction and the change to a more future proof dependency stack! I really appreciate this, since we recently decided to use ngx-grpc in an enterprise project.
Sorry for not reading the grpc/proto3 specs carefully, but grpc is a new technology for me and I'm just gathering first experience on that complicated stack. 🤓 Your approach for handling optional makes sense and it is the same way how grpc-web d.ts files look like. Everything is required/available per default, but messages are optional when the flag is set.
I could create a PR, if you don't mind.
from ngx-grpc.
I will try to summarize first, the first target is to have the following (without complexity that is introduced by optional):
- single scalar types (including enums) are always not-null, because every scalar has a default value (according to protobuf)
- single message types (including well-known types) are always optional (according to protobuf)
- repeated fields are always not-null, because the initial value is empty array (according to protobuf)
If the flag optional
is present, then... what should be changed?
As I see from proto3 field presence definition there are also some changes to the serialization / deserialization. The further difference is that it affects the JSON output format (toProtobufJSON
in context of ngx-grpc) and the original protobuf message implementation gets has
and clear
methods, but this in particular cannot exist in ngx-grpc by design (and actually make no sence since one can assign null values directly). Some of this complexity, I hope, is taken by the protoc itself, this needs to be checked separately.
This could be quite a big, definitely a breaking change.
from ngx-grpc.
Implemented by #57
from ngx-grpc.
Related Issues (20)
- update @improbable-eng/grpc-web dependency HOT 3
- Combine web worker and ImprobableEngGrpcWebClientModule? HOT 2
- How to reduce timeout or deadline? HOT 1
- do I need to handle connection close in server side HOT 4
- No licence specified at npm for @ngx-grpc/grpc-web-client HOT 1
- int64 is a string HOT 8
- Why are all properties generated in interfaces optional? HOT 3
- When I write in the settings file pbconf generate false. HOT 4
- How to decode grpc-web-text HOT 2
- Angular 16 issue HOT 1
- ngx-grpc client service throwing error HOT 1
- Running the plugin as a standalone executable throws Error: Cannot find module 'tslib' HOT 7
- [Question] GrpcHandler undefined HOT 1
- Question regarding google.api.http HOT 1
- Client Side Load Balancing
- Question: How can I use two GRPC service instances? HOT 5
- Any type usage help HOT 2
- Error: InjectionToken GRPC_CLIENT_FACTORY in tests after standalone migration
- Support stripping Enum prefixes
- Improper regex usage in the proto-gen getRelativeTypeName method HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-grpc.