0

I have a Gremlin application that I want to connect with Amazon Neptune. My application tries to save properties with enum values, but Neptune doesn't support this. Is there a way to configure the serializer (GraphBinaryMessageSerializerV1) to translate enums to strings, in a similar manner to JPA @Enumerated(STRING)? The configure method contains something that looks like it might be a hook, but it's not clear to me how to provide CustomTypeSerializers (or if that would work for abstract Enum).

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152

1 Answers1

1

I did some tests and I don't think GraphBinary can do what you want. The APIs force you to serialize the enum as CUSTOM which means that the server would also need to know about your custom serialization code in order to process it. Since you can't make that code available to Neptune, Neptune won't know how to deal with that. I was hoping it would be possible to use the custom serializer to coerce the value one-way from an unknown GraphBinary type to a known one (e.g. String) but it just didn't work out. I guess you would have to simply do g.addV().property('level',Level.HIGH.name()).

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks. I was already expecting incoming strings, so I was doing stuff like `elements['STATUS'] as Status` on reads, but I'd hoped to avoid the `as String` everywhere. I suppose this will be one more thing to roll into the infrastructure library I mentioned elsewhere. – chrylis -cautiouslyoptimistic- Jul 22 '21 at 16:17