-
Notifications
You must be signed in to change notification settings - Fork 5
feat: export protobuf #144
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
base: main
Are you sure you want to change the base?
Conversation
|
There is a mismatch in the develop commit history. The develop branch will be deleted. |
2a99ade to
f4b2f1a
Compare
36edab9 to
c8f265f
Compare
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
…tions Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
1efd74b to
f8da8b8
Compare
Signed-off-by: Ahmed Mohamed <[email protected]>
… a query type Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
Signed-off-by: Ahmed Mohamed <[email protected]>
|
@jdacoello the PR is now ready to be reviewed. The following has been changed:
|
Signed-off-by: Ahmed Mohamed <[email protected]>
| PASSENGERSIDE | ||
| } | ||
| ``` | ||
|
|
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.
| As the selection query is mandatory. The example must have a `type Query` to enable entry point(s) for the selection mechanism. | |
| ```gql | |
| type Query { | |
| cabin: Cabin | |
| } |
| ``` | ||
|
|
||
| The Protobuf exporter produces: | ||
|
|
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.
Give here the exact command that produces that output because now selection query is mandatory.
| #### Selection Query (Required) | ||
|
|
||
| The protobuf exporter requires a selection query to determine which types and fields to export: | ||
|
|
||
| ```bash | ||
| s2dm export protobuf --schema schema.graphql --selection-query query.graphql --output cabin.proto | ||
| ``` | ||
|
|
||
| Given a query file `query.graphql` that matches the schema above: | ||
|
|
||
| ```graphql | ||
| query Selection { |
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.
Assuming you define a selection query like:
query MyCustomSelection {
...
}The resulting proto root message of that query has the name Query:
message Query {
...
}Intead, the query name should be the proto message name like:
message MyCustomSelection {
...
}Please, modify the logic that is assigning that name to the proto message.
| #### Root Type Filtering | ||
|
|
||
| Use the `--root-type` flag in combination with the selection query to further filter the export: | ||
|
|
||
| ```bash | ||
| s2dm export protobuf --schema schema.graphql --selection-query query.graphql --output cabin.proto --root-type Cabin | ||
| ``` | ||
|
|
||
| This will include only the `Cabin` type and all types transitively referenced by it from the selection query. |
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.
Can you add an example of this? I am not understanding the point of introducing this --root-type when we have already the selection query. Isn't the selection query enough?
| ```graphql | ||
| type Vehicle { | ||
| adas: ADAS | ||
| } | ||
|
|
||
| type ADAS { | ||
| abs: ABS | ||
| } | ||
|
|
||
| type ABS { | ||
| isEngaged: Boolean | ||
| } | ||
| ``` | ||
|
|
||
| Flatten mode produces: | ||
|
|
||
| ```protobuf | ||
| syntax = "proto3"; | ||
|
|
||
| import "google/protobuf/descriptor.proto"; | ||
| import "buf/validate/validate.proto"; | ||
|
|
||
| extend google.protobuf.MessageOptions { | ||
| string source = 50001; | ||
| } | ||
|
|
||
| message Message { | ||
| bool Vehicle_adas_abs_isEngaged = 1; | ||
| } |
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.
Example is incomplete and not replicable because selection query is mandatory and not in the example.
This PR implements support for exporting
.protofiles.s2dm export protobuf --schema /path/to/schema --output output.proto --selection-query /path/to/selection/query [--package-name package.name] [--flatten-naming]Based on #146.