-
Notifications
You must be signed in to change notification settings - Fork 75
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
findCustomScalarOption
but for repeated options?
#607
Comments
Hi @Jayatubi. You can retrieve repeated options using a message wrapper and the // custom_options.proto
extend google.protobuf.MethodOptions {
optional FooOptions foo_method_option = 50007;
}
message FooOptions {
repeated string many = 1;
}
// foo_service.proto
import "custom_options.proto";
service FooService {
rpc Get(GetRequest) returns (GetResponse) {
option (foo_method_option) = {
many: ["a", "b", "c"],
};
}
} You can retrieve the options using a generated type by first generating the file which defines the custom option type. Then, import and pass this type to the import { FooOptions } from "./gen/proto/custom_options_pb.js";
const option = findCustomMessageOption(method, 50007, FooOptions)
console.log(option);
/*
* {
* many: ["a", "b", "c"],
* }
*/ For more info, check out our plugin docs |
The wrapper message option looks like but I think a plain repeated options should also be useful. No need to change any of current interfaces. Just add a new one would be better. |
Yeah, understood. We actually explicitly opted against this for now to keep the API simpler and feel that the message wrapper is a viable alternative. Going to close this for now, since I don't see us implementing this anytime soon, but we will definitely reopen if we decide to revisit. |
It is valid to define a repeated options for a message such as:
However, the function
findCustomScalarOption
could be used only to retrieve the first option since it was implemented as:How about to provide a new function, maybe named
findCustomRepeatedOptions
, to retrieve all the matched options?For example:
The text was updated successfully, but these errors were encountered: