Referring to predicates or classes as you do to nodes

it is impossible in dql to ask ‘give me all fields and edges “on” a node’ because you have to ask for everything you want to access. Storage is organized by predicate, not by node - so you cannot grab a ‘whole node’. Using expand() with the type system can help organize and auto-fill those fields, but does not mean some other field could not exist ‘on’ that node that is not within your types. This can be enforced in application code though.

Expand actually does give you edges as well, but only ones defined in the type system.

so given

type MyType {
  id
  myfield 
  myedge
}

the query

{q(func: eq(id,"blah")){
  expand(MyType) {
    expand(MyType)
    uid
  }
}}

is equivalent to:

{q(func: eq(id,"blah")){
  id
  myfield
  myedge {
    uid
    id
    myfield
  }
}}

when using expand(_all_) it basically looks up the values of dgraph.type on the nodes in question, and applies every type listed there to expand(). Note expand can be used with specified types without recording those type in dgraph.type

2 Likes