diff --git a/rejoiner-guice/src/test/java/com/google/api/graphql/rejoiner/RejoinerIntegrationTest.java b/rejoiner-guice/src/test/java/com/google/api/graphql/rejoiner/RejoinerIntegrationTest.java index 42b93e4..dde7f5a 100644 --- a/rejoiner-guice/src/test/java/com/google/api/graphql/rejoiner/RejoinerIntegrationTest.java +++ b/rejoiner-guice/src/test/java/com/google/api/graphql/rejoiner/RejoinerIntegrationTest.java @@ -276,7 +276,7 @@ public void executionQueryWithAllFields() { .put("intField", (long) 1) .put("RenamedField", "name") .put("testInnerProto", ImmutableMap.of("foo", "foooo")) - .put("bytesField", ByteString.copyFromUtf8("b-y-t-e-s")) + .put("bytesField", "b-y-t-e-s") .build()))); } diff --git a/rejoiner/src/main/java/com/google/api/graphql/rejoiner/ProtoScalars.java b/rejoiner/src/main/java/com/google/api/graphql/rejoiner/ProtoScalars.java index 9a11e2e..ed03ebe 100644 --- a/rejoiner/src/main/java/com/google/api/graphql/rejoiner/ProtoScalars.java +++ b/rejoiner/src/main/java/com/google/api/graphql/rejoiner/ProtoScalars.java @@ -81,12 +81,12 @@ private ProtoScalars() {} public static final GraphQLScalarType BYTES = GraphQLScalarType.newScalar() .coercing( - new Coercing() { + new Coercing() { @Override - public ByteString serialize(Object dataFetcherResult) + public String serialize(Object dataFetcherResult) throws CoercingSerializeException { if (dataFetcherResult instanceof ByteString) { - return (ByteString) dataFetcherResult; + return ((ByteString) dataFetcherResult).toStringUtf8(); } else { throw new CoercingSerializeException( "Invalid value '" + dataFetcherResult + "' for Bytes"); @@ -119,7 +119,7 @@ public ByteString parseLiteral(Object input) throws CoercingParseLiteralExceptio }) .name("Bytes") .description( - "Scalar for proto type bytes." + "Scalar for proto type byte as a utf8-encoded string" + " May contain any arbitrary sequence of bytes no longer than 2^32.") .build(); }