Closed DianaSuvorova closed 4 years ago
Here is what I ended up doing. Not sure if it is the most optimal solution. But this works. Thanks @siderakis.
DataFetcher anyValueHexFetcher =
new DataFetcher<String>() {
@Override
public String get(DataFetchingEnvironment environment) {
return Hex.encodeHexString(
((Any) ((DataFetchingEnvironmentImpl) environment).getSource())
.getValue()
.toByteArray());
}
};
@SchemaModification
TypeModification typeModification =
Type.find("google_protobuf_Any")
.addField(
GraphQLFieldDefinition.newFieldDefinition()
.name("valueHEX")
.type(Scalars.GraphQLString)
.dataFetcher(anyValueHexFetcher)
.build());
The data transferred for the
google_protobuf_Any
looks like the following:typeUrl string is correct while the value is in the format that can't be decoded. This looks like a result of
ByteString.toString()
.Is there a way to do actual byte array to string decoding on rejoiner side and transfer it as a value.