0

My aim is to create an AWS-AppSync GraphQL API that implements the Relay Cursor Connections Specification. Specifically I want to add opaque cursors for some Elasticsearch queries. My cursor would be the sort values array for the search_after API. But to make them opaque I would like to stringify and base64 encode them before sending them to the client.

I know that AppSync exposes base64 encode and decode through its $util object. But decode returns a type of byte[] and not String. So my Question boils down to how to convert byte[] to String in Velocity?

Can we use the underlying Java for something like this:

new String(bytes)

Unfortunately I don't know which classes are in the AppSync Velocity Context.

Thanks in advance :)

Per Salmi
  • 1,398
  • 1
  • 14
  • 28

1 Answers1

0

Have you tried Base64.getEncoder().encodeToString(bytes)?

Sunny
  • 176
  • 4