Annotations

Annotations are named values associated with schema items and are designed to hold arbitrary schema-level metadata represented as a str.

There is a number of annotations defined in the standard library. The following are the annotations which can be set on any schema item:

  • title

  • description

For example, consider the following declaration:

type Status {
    annotation title := 'Activity status';
    annotation description := 'All possible user activities';

    required property name -> str {
        constraint exclusive
    }
}

The above annotations can be extracted via schema introspection queries and used to create a descriptive UI for an admin tool:

db> 
... 
... 
... 
... 
... 
... 
... 
... 
WITH MODULE schema
SELECT ObjectType {
    name,
    annotations: {
        name,
        @value
    }
}
FILTER .name = 'default::Status';
{
    Object {
        name: 'default::Status',
        annotations: {
            Object {
                name: 'std::description',
                @value: 'All possible user activities'
            },
            Object {
                name: 'std::title',
                @value: 'Activity status'
            }
        }
    }
}

Annotation SDL, DDL, and introspection.