Skip to main content
Version: Next

Aliases

Syntax Examples:

  • aliasName : predicate
  • aliasName : predicate { ... }
  • aliasName : varName as ...
  • aliasName : count(predicate)
  • aliasName : max(val(varName))

An alias provides an alternate name in results. Predicates, variables and aggregates can be aliased by prefixing with the alias name and :. Aliases do not have to be different to the original predicate name, but, within a block, an alias must be distinct from predicate names and other aliases returned in the same block. Aliases can be used to return the same predicate multiple times within a block.

Query Example: Directors with name matching term Steven, their UID, English name, average number of actors per movie, total number of films, and the name of each film in English and French.

{
ID as var(func: allofterms(name@en, "Steven")) @filter(has(director.film)) {
director.film {
num_actors as count(starring)
}
average as avg(val(num_actors))
}

films(func: uid(ID)) {
director_id : uid
english_name : name@en
average_actors : val(average)
num_films : count(director.film)

films : director.film {
name : name@en
english_name : name@en
french_name : name@fr
}
}
}