I insert a node of API key set and set an existing user as ist owner by using the User.api_key_sets predicate
Then when I try to delete this node with S * * it deletes all of its data but it doesn’t remove it from the user node and I left with a ghost node:
Yes and no, in the case you don’t explicitly state the entities Dgraph should “infer” all incoming edges and that would be a bit expensive to built in the delete operation - and over time a LOT expensive. The upsert solves this as I’ve shown.
But, in other cases, if you know both entities. You can do like this.
Ok so I always have to delete the node from both direction.
Do you think that in the future you’ll be able to implement the delete operation in a way that if it gets one uid (not a triple) it delete the node completely?
well, there are two nodes involved. I think your question is related to the incoming edges. And the answer is no, hardly an incoming edges delete op will be implemented.
There are some discussions about this here and old ones in Github issues. And the conclusion is that It doesn’t worth to implement. Is better for the user to do it manually or via Upsert other than implementing such an expensive feature that can happen to bring unusual behaviors.