Delete Mutation in Ratel does not delete edges on local machine?

I ran the following mutation in Ratel on my local machine, localhost:8080

{
    set {
       <_:test> <name> 'test'.
       <_:test_1> <name> 'test_1'.
        <_:test> <rel> <_:test_1>
    }
}

Assume dgraph assigns uid 0xabc11 to _:test
Next I ran the mutation:

{
  delete{
      <0xabc11> * * . 
   }
}

when I query

{
    test(func:  uid(0xabc11)){
      uid
      rel {
        uid
      }
  }
}

I found that _:test is still connected to _:test_1

what is the correct way of delete both the predicate and the edge at the same time?

Update: After further testing I notice that the delete pattern <uid> * * . is not working on my localhost. I am not sure why.

Mutation Delete:

<uid> <rel> * . Works
<uid> <name> * . Works
<uid> * * . Doesn't work

Update 2: So i tested the query:

{
  tree(func:uid(0xabc11))
  {
    _predicate_
    expand(_all_) {}
  }
}

It returns nothing… no predicates no edges

But the query:

{
  tree(func:uid(0xabc11))
  {
       name
  }
}

returns the name that was supposed to be deleted?

Update 3: I even tried using the JSON format “delete”:[{“uid”:“0xabc11”}] but it still has the name when queried.

I feel like I am missing something really basic here.

You have to have the 'dgraph.type" in your dataset and also define the Type Schema.

e.g:

{
    set {
       _:test    <name>         "test"        . 
       _:test    <dgraph.type>  "User".       . 
       _:test_1  <name>         "test_1"      .
       _:test_1  <dgraph.type>  "User"        . 
       _:test    <rel>          _:test_1      .
    }
}

And add the Type Definition

type User {
  name
  rel
}

Now you are able to delete with the patterns you used.

Thanks its working now.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.