Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
support json_name proto annotation for renaming field names in GraphQ…
Browse files Browse the repository at this point in the history
…L schema.

also bumping version to release 0.2.1.
  • Loading branch information
siderakis committed Nov 29, 2018
1 parent 5bc479d commit 21b355c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rejoiner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<groupId>com.google.api.graphql</groupId>
<artifactId>rejoiner</artifactId>
<name>Rejoiner</name>
<version>0.2.0</version>
<version>0.2.1</version>
<description>Generating GraphQL schemas from Protobufs.</description>
<url>https://github.com/google/rejoiner</url>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ private static Object call(Object object, String methodName) {
return method.invoke(object);
} catch (NoSuchMethodException e) {
return null;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
Expand All @@ -154,7 +152,7 @@ public GraphQLFieldDefinition apply(FieldDescriptor fieldDescriptor) {
.type(convertType(fieldDescriptor))
.dataFetcher(
new ProtoDataFetcher(convertedFieldName))
.name(convertedFieldName);
.name(fieldDescriptor.getJsonName());
builder.description(DescriptorSet.COMMENTS.get(fieldDescriptor.getFullName()));
if (fieldDescriptor.getOptions().hasDeprecated()
&& fieldDescriptor.getOptions().getDeprecated()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void convertShouldWorkForMessage() {
GraphQLObjectType result = ProtoToGql.convert(Proto1.getDescriptor(), null);
assertThat(result.getName())
.isEqualTo("javatests_com_google_api_graphql_rejoiner_proto_Proto1");
assertThat(result.getFieldDefinitions()).hasSize(5);
assertThat(result.getFieldDefinitions()).hasSize(6);
}

@Test
Expand All @@ -74,9 +74,10 @@ public void convertShouldWorkForEnums() {
@Test
public void checkFieldNameCamelCase() {
GraphQLObjectType result = ProtoToGql.convert(Proto1.getDescriptor(), null);
assertThat(result.getFieldDefinitions()).hasSize(5);
assertThat(result.getFieldDefinitions()).hasSize(6);
assertThat(result.getFieldDefinition("intField")).isNotNull();
assertThat(result.getFieldDefinition("camelCaseName")).isNotNull();
assertThat(result.getFieldDefinition("RenamedField")).isNotNull();
}

@Test
Expand Down

0 comments on commit 21b355c

Please sign in to comment.