Delete Root node and all of its hierarchy

Well, that type of procedure is easy with an upsert query and recurse.

e.g:

upsert {
  query {
    var(func: eq(myRoot, "structure 1")) @recurse {
      v as uid
      N1 as nested1
      N2 as nested2
      N3 as nested3
      N4 as nested4
      N5 as nested5
    }
  }

  mutation {
   delete {
      uid(v)  * * .
      uid(N1) * * .
      uid(N2) * * .
      uid(N3) * * .
      uid(N4) * * .
      uid(N5) * * .
    }
  }
}

This will delete all connected objects to the root. To delete incoming edges is a bit different. You will need the reverse index and add it in the recurse block. But you would delete as uid(Incoming) <connectedto> * .

1 Like