Query for list of predicates from a single node


(Ramith) #1

I have a dgraph schema which contains several different entity-types. While dgraph does not explicitly contain entity types, I added an additional edge called entity_type to help disambiguate nodes easily. Each entity type has 1 or more edges (like any graph). In addition, each node has an xid that uniquely identifies it.

My requirement is that when I am given an xid, I need to find out all edges outbound from it. I assumed this was very simple, because a query such as:

 {
    q(func: eq(entity_type, "type_val")) @filter(eq(xid, "xid_val"))  {
	    _predicate_
    }
}

Or more simply,

{
    q(func: eq(xid, "xid_val"))  {
	    _predicate_
    }
}

would give me the predicates i.e. the outbound edges from this node.

However, this returns a blank result, even though edges exist for that node.

Alternately, a query that begins with a match over several results such as:

 {
    q(func: has(valid_reln_for_entity_type ) )  {
	  xid  
          _predicate_
    }
}

returns a massive list of all nodes that match my entity_type with their xids and predicates for each node.

I am able to access predicates if I query for all predicates of all nodes of an entity type, but not for a single node when I query for it.

Why is this behavior occurring, and how do I modify my query to get it to work?


(Michel Conrado) #2

What version are you? _predicate_ was removed in favor of the new Dgraph’s Type System.