Skip to content

Commit

Permalink
initial commit for early review
Browse files Browse the repository at this point in the history
  • Loading branch information
siderakis committed Apr 22, 2019
1 parent cedc123 commit 7d1d59d
Show file tree
Hide file tree
Showing 10 changed files with 436 additions and 353 deletions.
245 changes: 124 additions & 121 deletions rejoiner/pom.xml
Expand Up @@ -16,7 +16,9 @@
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- To check for updates: mvn versions:display-dependency-updates -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down Expand Up @@ -79,7 +81,7 @@
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>2018-11-28T08-13-20-3ada93e</version>
<version>2019-04-09T05-29-53-bd9240c</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down Expand Up @@ -159,9 +161,9 @@

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
Expand All @@ -186,120 +188,121 @@
<version>2.3.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocExecutable>/usr/local/bin/protoc</protocExecutable>
<writeDescriptorSet>true</writeDescriptorSet>
<descriptorSetFileName>descriptor_set.desc</descriptorSetFileName>
<descriptorSetOutputDirectory>${build.directory}/test-classes/META-INF/proto</descriptorSetOutputDirectory>
<includeSourceInfoInDescriptorSet>true</includeSourceInfoInDescriptorSet>
<includeDependenciesInDescriptorSet>true</includeDependenciesInDescriptorSet>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<configuration>
<excludes>
<exclude>**/*AutoValue_*</exclude>
<exclude>**/generated-sources/**/*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
</plugins>
</build>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocExecutable>/usr/local/bin/protoc</protocExecutable>
<writeDescriptorSet>true</writeDescriptorSet>
<descriptorSetFileName>descriptor_set.desc</descriptorSetFileName>
<descriptorSetOutputDirectory>${build.directory}/test-classes/META-INF/proto
</descriptorSetOutputDirectory>
<includeSourceInfoInDescriptorSet>true</includeSourceInfoInDescriptorSet>
<includeDependenciesInDescriptorSet>true</includeDependenciesInDescriptorSet>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<configuration>
<excludes>
<exclude>**/*AutoValue_*</exclude>
<exclude>**/generated-sources/**/*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
</plugins>
</build>
</project>
Expand Up @@ -23,6 +23,10 @@ final class Annotations {

private Annotations() {}


@Retention(RetentionPolicy.RUNTIME)
@Qualifier
@interface SchemaBundles {}
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
@interface Mutations {}
Expand Down
@@ -0,0 +1,24 @@
package com.google.api.graphql.rejoiner;

import com.google.auto.value.AutoValue;
import graphql.schema.DataFetcher;
import graphql.schema.GraphQLFieldDefinition;

/** A GraphQL field definition with it's data fetcher. */
@AutoValue
public abstract class FieldDefinition<T> {
abstract String parentTypeName();

abstract GraphQLFieldDefinition field();

abstract DataFetcher<T> dataFetcher();

static <T> FieldDefinition create(
String parentTypeName, GraphQLFieldDefinition field, DataFetcher<T> dataFetcher) {
return new AutoValue_FieldDefinition(parentTypeName, field, dataFetcher);
}

String fieldName() {
return field().getName();
}
}
Expand Up @@ -119,7 +119,10 @@ public Object get(DataFetchingEnvironment environment) {
return null;
}
Map<?, ?> map = (Map<?, ?>) mapValue;
return map.entrySet().stream().map(entry -> ImmutableMap.of("key", entry.getKey(), "value", entry.getValue())).collect(toImmutableList());
return map.entrySet()
.stream()
.map(entry -> ImmutableMap.of("key", entry.getKey(), "value", entry.getValue()))
.collect(toImmutableList());
}
if (type instanceof GraphQLEnumType) {
Object o = call(source, "get" + LOWER_CAMEL_TO_UPPER.convert(name));
Expand All @@ -146,12 +149,12 @@ private static Object call(Object object, String methodName) {
@Override
public GraphQLFieldDefinition apply(FieldDescriptor fieldDescriptor) {
String fieldName = fieldDescriptor.getName();
String convertedFieldName = fieldName.contains("_") ? UNDERSCORE_TO_CAMEL.convert(fieldName) : fieldName;
String convertedFieldName =
fieldName.contains("_") ? UNDERSCORE_TO_CAMEL.convert(fieldName) : fieldName;
GraphQLFieldDefinition.Builder builder =
GraphQLFieldDefinition.newFieldDefinition()
.type(convertType(fieldDescriptor))
.dataFetcher(
new ProtoDataFetcher(convertedFieldName))
.dataFetcher(new ProtoDataFetcher(convertedFieldName))
.name(fieldDescriptor.getJsonName());
builder.description(DescriptorSet.COMMENTS.get(fieldDescriptor.getFullName()));
if (fieldDescriptor.getOptions().hasDeprecated()
Expand Down Expand Up @@ -211,27 +214,27 @@ static GraphQLObjectType convert(Descriptor descriptor, GraphQLInterfaceType nod
.build())
.findFirst();

if (relayId.isPresent()) {
return GraphQLObjectType.newObject()
.name(getReferenceName(descriptor))
.withInterface(nodeInterface)
.field(relayId.get())
.fields(
graphQLFieldDefinitions
.stream()
.map(
field ->
field.getName().equals("id")
? GraphQLFieldDefinition.newFieldDefinition()
.name("rawId")
.description(field.getDescription())
.type(field.getType())
.dataFetcher(field.getDataFetcher())
.build()
: field)
.collect(ImmutableList.toImmutableList()))
.build();
}
// if (relayId.isPresent()) {
// return GraphQLObjectType.newObject()
// .name(getReferenceName(descriptor))
// .withInterface(nodeInterface)
// .field(relayId.get())
// .fields(
// graphQLFieldDefinitions
// .stream()
// .map(
// field ->
// field.getName().equals("id")
// ? GraphQLFieldDefinition.newFieldDefinition()
// .name("rawId")
// .description(field.getDescription())
// .type(field.getType())
// .dataFetcher(field.getDataFetcher())
// .build()
// : field)
// .collect(ImmutableList.toImmutableList()))
// .build();
// }

return GraphQLObjectType.newObject()
.name(getReferenceName(descriptor))
Expand All @@ -243,7 +246,10 @@ static GraphQLObjectType convert(Descriptor descriptor, GraphQLInterfaceType nod
static GraphQLEnumType convert(EnumDescriptor descriptor) {
GraphQLEnumType.Builder builder = GraphQLEnumType.newEnum().name(getReferenceName(descriptor));
for (EnumValueDescriptor value : descriptor.getValues()) {
builder.value(value.getName(), value.getName(), DescriptorSet.COMMENTS.get(value.getFullName()),
builder.value(
value.getName(),
value.getName(),
DescriptorSet.COMMENTS.get(value.getFullName()),
value.getOptions().getDeprecated() ? "deprecated in proto" : null);
}
return builder.build();
Expand Down

0 comments on commit 7d1d59d

Please sign in to comment.