New ACM paper, free-tier cloud, and open-source license

plays

The plays keyword is used in TypeQL schema to define a valid player of a role in a relation type.

Syntax

The syntax of a plays statement includes:

  • Subject — type label of a type to play the role

  • Predicate — the plays keyword

  • Object — scoped type label of a role

Syntax
<type> plays <relation-type:role> [as overridden-type];

An optional override can be added at the end.

Behavior

TypeQL statements with the plays keyword can be used only in Define and Undefine queries.

The plays keyword adds an ability to play a role to a schema.

Usage in a schema definition

For this example, use a database with the IAM schema and sample data loaded.

Since in Define and Undefine queries you can’t use variables, both subject and object can only be type labels. The object is always a scoped type label that consists of a relation type and a role separated by a colon.

For example, to define the subject type to be able to play the subject role in the premission relation type, use:

Define role query example
define
subject plays permission:subject;

To remove the new role, use:

Undefine query example
undefine
subject plays permission:subject;

Usage with override

For this example, use a database with the IAM schema and sample data loaded.

By default, a subtype of a relation type inherits all roles that were defined for its supertype. To override an inherited role, use the as keyword. The overridden new role must be a subtype of the inherited role.

Let’s see an example, of a schema, where the owned role of the ownership relation type gets overridden by the object role:

Override owned attribute type example
define
subject plays permission:manager as subject;

Learn more

Learn more about type statement in TypeQL.

Learn about types in TypeQL.

Provide Feedback