How to bulk delete nodes or cascade delete nodes?

You should use Upsert Block for this

upsert {
  query {
    V as var(func: type(Group)) @filter(eq(name, "MyGroup")){
      M as members
      P as posts
    }
  }

  mutation {
    delete {
      uid(V) * * .
      uid(M) * * .
      uid(P) * * .
    }
  }
}

Can be also like this using recurse (Which is similar to the concept behind the word “cascade” that you used):

upsert {
  query {
    V as var(func: type(Group)) @filter(eq(name, "MyGroup")) @recurse(depth: 5) {
      REST uid
      name
      subgroup
    }
  }

  mutation {
    delete {
      uid(V) * * .
      uid(REST) * * .
    }
  }
}

Cheers.

3 Likes