Deleting a Node using NQuad in Mutation

I am trying to delete a node using the del method for mutation. But it gives me below error:

Mycode:

m.Del = append(m.Del, &api.NQuad{
			Subject:   result.Objects[0].Certificates[0].UID,
			Predicate: "_STAR_ALL",
			ObjectId:  "_STAR_ALL",
		})

Error Message:

Error:      	Received unexpected error:
        	            	rpc error: code = Unknown desc = Only valid wildcard delete patterns are 'S * *' and 'S P *': subject:"0x16045" predicate:"_STAR_ALL" object_id:"_STAR_ALL"

Also, I tried using DelNQuads methods but I get this error:

Note: I already know that we can do this by Json but I am specifically looking for NQuad solution.

Hi @zebon43,

Welcome to Dgraph Community !!

I see that you want to use wildcard for objects, predicates.
To to that, you will have to pass this parameter as well to &api.NQuad,

ObjectValue: &api.Value{Val: &api.Value_DefaultVal{DefaultVal: "_STAR_ALL"}} along with passing ObjectId: ""

Thanks Rajas. This worked. Is there any document where I can check why we need to do this? As I want to use the delNQuad method as well but there is some issue with the data type. And i really don’t know what is the problem.

1 Like

@zebon43,

Thanks for your reply.
Currently, there is no documentation or a document containing ways to use NQuad.
I have reported this back to be included in documentation or examples.

To unblock you now:
As Dgraph’s code is open source, you can find examples of using DelNquads method in the codebase and related tests.

Dgraph Repository: GitHub - dgraph-io/dgraph: Native GraphQL Database with graph backend