google / rejoiner

Generates a unified GraphQL schema from gRPC microservices and other Protobuf sources
https://google.github.io/rejoiner/
Apache License 2.0
3.67k stars 139 forks source link

Propagate comments from protobuf to GraphQL schema #58

Closed dsborets closed 5 years ago

dsborets commented 5 years ago

I'm proposing to use standard protobuf description set file as a source of comments in order to propagate comments from proto to GraphQL schema

The proto description set file could be generated by protobuf plugin:

Maven:

   <plugin>
       <groupId>org.xolstice.maven.plugins</groupId>
       <artifactId>protobuf-maven-plugin</artifactId>
       <version>0.5.1</version>
       <configuration>
         <writeDescriptorSet>true</writeDescriptorSet>
         <descriptorSetFileName>descriptor_set.desc</descriptorSetFileName>
         <descriptorSetOutputDirectory>${build.directory}/test-classes/META-INF/proto</descriptorSetOutputDirectory>
         <includeSourceInfoInDescriptorSet>true</includeSourceInfoInDescriptorSet>
         <includeDependenciesInDescriptorSet>true</includeDependenciesInDescriptorSet>
       </configuration>
   .....
    </plugin>

Grails:

protobuf {
    protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
    plugins {
        grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
    }
    generateProtoTasks {
        ofSourceSet('main').each{task ->
            task.generateDescriptorSet = true
            task.descriptorSetOptions.includeImports = true
            task.descriptorSetOptions.includeSourceInfo = true
            task.descriptorSetOptions.path = "${buildDir}/resources/main/META-INF/proto/descriptor_set.desc"
            task.plugins {
                grpc {}
            }
        }
    }
}

The generated protofile description file must be named as descriptor_set.desc and located in META-INF/proto of the final jar file

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 145


Changes Missing Coverage Covered Lines Changed/Added Lines %
rejoiner/src/main/java/com/google/api/graphql/rejoiner/SchemaModule.java 6 7 85.71%
rejoiner/src/main/java/com/google/api/graphql/rejoiner/DescriptorSet.java 46 57 80.7%
<!-- Total: 58 70 82.86% -->
Totals Coverage Status
Change from base Build 113: 1.4%
Covered Lines: 859
Relevant Lines: 1990

💛 - Coveralls
dsborets commented 5 years ago

Related to issue

siderakis commented 5 years ago

Reviewing this now.

siderakis commented 5 years ago

This looks good, we can refactor to using an ImmtableMap later as well as updating the docs

siderakis commented 5 years ago

Thanks!

dsborets commented 5 years ago

:+1: Thank you for quick review