Bug in cascade directive?

I have a schema, where, a person can subscribe to multiple services “service1”, “service2” etc…
Starting with user id say “1”, I want to get his “owns” predicate, which has subscribed to “service1”

Below query with @cascade works fine, and I get exactly one uid

{
  my_activities(func: eq(Id, 1)) @cascade {
    owns {
      uid
      subscribedTo @filter(eq(name, "service1"))
    }
  }
}

But when I use the same query in upsert, behavior is little bit strange. Even with cascade, I see multiple uid being returned.

Does this mean that cascade works only in query and not in upsert block?

upsert{
  query{
   my_activities(func: eq(Id, 1)) @cascade {
	    owns {
	      subscribedTo @filter(eq(name, "Service1"))
	      instance as uid
	    }
    }
   mutation @if(eq(len(instance), 2) ) {
    # this block executes!!!
   }
   mutation @if(eq(len(instance), 1) ) {
     # this block DOESNOT execute. I was expecting this block to be executed.
   }
  }

This indeed seems like a bug to me. Will you file a GitHub issue for this at https://github.com/dgraph-io/dgraph/issues/new and we will look into it as soon as we can. Thanks

I have opened new issue here Bug in query variables whe used with @cascade · Issue #4690 · dgraph-io/dgraph · GitHub

1 Like