title: How to drop a subgraph in Tinkerpop (OrientDB) gremlin query?
body: <p>Requirement is to drop this subgraph if I have <code>runId</code> and <code>appId</code>. Application can have multiple such appId and thus should be deleted only if no <code>appId</code> is attached to it.</p>
  
  <p>I have tried the below query to drop the subgraph, but only <code>IO</code> and <code>appRun</code> gets dropped. The <code>iRecord</code> &amp; <code>oRecord</code> don't get dropped. Is this because I loose the gremlin pointer? So question is how to delete the <code>iRecord</code> and <code>oRecord</code>. </p>
  
  <p>I was planning to delete the <code>appId</code> in second traversal call. So can I check if the <code>appId</code> has no more connected <code>runId</code> and drop <code>appId</code> in the same traversal.</p>
  
  <pre><code>db.getTraversal()
                  .V().has("aRun", "runId", runId).as("aRun")
                  .outE("hasIO")
                  .inV().hasLabel("io").as("io")
                  .sideEffect(outE("output").inV().has("oRecord").drop())
                  .sideEffect(inE("input").outV().has("iRecord").drop())
                  .sideEffect(select("aRun").drop())
                  .sideEffect(select("io").drop())
                  .iterate();
  </code></pre>
  
  <p>I also tried version of answer provided here: <a href="https://stackoverflow.com/questions/51547985/gremlin-drop-multiple-vertices">Link</a></p>
  
  <pre><code>db.getTraversal().
    V().has("aRun", "runId", runId)
    emit().
    repeat(out()).
    fold().
    unfold().
    drop()
  </code></pre>
  
  <p>But this will delete the <code>oRecord</code>, <code>aRun</code> and <code>io</code> but not the <code>iRecord</code>. And question of how to drop <code>appId</code> remains.</p>
  
  <p>Thanks</p>
  
  <p><a href="https://i.stack.imgur.com/inmjn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/inmjn.png" alt="Sample Subgraph"></a></p>
  
  <p>pom.xml:</p>
  
  <pre><code>&lt;dependency&gt;
   &lt;groupId&gt;com.orientechnologies&lt;/groupId&gt;
   &lt;artifactId&gt;orientdb-gremlin&lt;/artifactId&gt;
   &lt;version&gt;3.0.25&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>