title: how to return subgraph from gremlin that is in an easily consumable format for Java
body: <p>I am very frustrated about very simple things when I try to do a single traversal and bring a lot of stuff from DSE Graph 5.0 at once using Gremlin..</p>
  
  <p>In my simplified case I have:</p>
  
  <ul>
  <li>1 entity with specific uuid</li>
  <li>entity can have zero (see optional) or more types</li>
  <li>I need to be able to return the <code>entity</code> and the <code>types</code></li>
  </ul>
  
  <p>What I have so far that works is very ugly :(</p>
  
  <pre><code>List list = g.V().hasLabel("Entity").has("uuid","6708ec6d-4518-4159-9005-9e9d642f157e").as("entity")
          .optional(outE("IsOfType").as("types"))
          .select("entity", "types").toList();
  List&lt;Edge&gt; typeEdges = new ArrayList&lt;&gt;();
  Vertex entityV = null;
  for (Object obj : list) {
      entityV = ((Vertex)((LinkedHashMap) obj).get("entity"));
      Edge typeEdge = ((Edge)((LinkedHashMap) obj).get("types"));
      typeEdges.add(typeEdge);
  }
  </code></pre>
  
  <p>each row in the list has the entity and one of the types :/</p>
  
  <p>I am doing all this because Vertex doesn't come with populated <code>edges()</code> based on the traversal in DSE 5.0 Fluent API. So either I am stuck with multiple traversals or a single huge terrible traversal that is very difficult to deserialize in Java Objects or I have to pass gremlin queries as String but that will not return Gremlin Vertex objects but DSE instead :(</p>
  
  <p>In my less simplified case I want to return multiple entities of the above with their respective types how can this be done? </p>
  
  <p>Finally what is a good approach that will lead to reusable code for custom object mapping of a subgraph with different type of objects?</p>
  
  <p>Thank you in advance for the help!</p>