Aliases​

This section assumes a basic understanding of EdgeQL. If you aren’t familiar with it, feel free to skip this page for now.

An alias is a pointer to a set of values. This set is defined with an arbitrary EdgeQL expression.

Like computed properties, this expression is evaluated on the fly whenever the alias is referenced in a query. Unlike computed properties, aliases are defined independent of an object type; they are standalone expressions.

Scalar alias

  1. alias digits := {0,1,2,3,4,5,6,7,8,9};

Object type alias

The name of a given object type (e.g. User) is itself a pointer to the set of all User objects. After declaring the alias below, you can use User and UserAlias interchangably.

  1. alias UserAlias := User;

Object type alias with computeds

Object type aliases can include a shape that declare additional computed properties or links.

  1. type Post {
  2. required property title -> str;
  3. }
  4. alias PostAlias := Post {
  5. trimmed_title := str_trim(.title)
  6. }

In effect, this creates a virtual subtype of the base type, which can be referenced in queries just like any other type.

Query alias

Aliases can correspond to an arbitrary EdgeQL expression, including entire queries.

  1. type BlogPost {
  2. required property title -> str;
  3. required property is_published -> bool;
  4. }
  5. alias PublishedPosts := (
  6. select BlogPost
  7. filter .is_published = true
  8. );

All aliases are reflected in the database’s built-in GraphQL schema.

See also

SDL > Aliases

DDL > Aliases

Cheatsheets > Aliases