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

returning bytes as a utf8-encoded string #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ private ProtoScalars() {}
public static final GraphQLScalarType BYTES =
GraphQLScalarType.newScalar()
.coercing(
new Coercing<ByteString, ByteString>() {
new Coercing<ByteString, String>() {
@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");
Expand Down Expand Up @@ -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();
}