Hot to query schema type of node


(Johannes) #1

Hey there,

How can I get the type of a node? E.g. in my schema I have types “Person”, “Post”, “Comment”, … How can I return the value of a type, not a predicate?

{
q(func: regexp(name, /.*new.*/i)) {
    name
    uid
    type # ← not the predicate "type" but the node’s type
  }
}

My workaround is currently an additional type predicate for every type.


(Michel Conrado) #2

Use “dgraph.type” in your query.