Search
ctrl/
Ask AI
Light
Dark
System

Scalar types

This section describes introspection of scalar types.

Introspection of the schema::ScalarType:

Copy
db> 
... 
... 
... 
... 
... 
... 
... 
... 
... 
... 
with module schema
select ObjectType {
    name,
    links: {
        name,
    },
    properties: {
        name,
    }
}
filter .name = 'schema::ScalarType';
{
    Object {
        name: 'schema::ScalarType',
        links: {
            Object { name: '__type__' },
            Object { name: 'annotations' },
            Object { name: 'bases' },
            Object { name: 'constraints' },
            Object { name: 'ancestors' }
        },
        properties: {
            Object { name: 'default' },
            Object { name: 'enum_values' },
            Object { name: 'id' },
            Object { name: 'abstract' },
            Object { name: 'name' }
        }
    }
}

Introspection of the built-in scalar str:

Copy
db> 
... 
... 
... 
... 
... 
... 
... 
... 
... 
... 
... 
with module schema
select ScalarType {
    name,
    default,
    enum_values,
    abstract,
    bases: { name },
    ancestors: { name },
    annotations: { name, @value },
    constraints: { name },
}
filter .name = 'std::str';
{
    Object {
        name: 'std::str',
        default: {},
        enum_values: {},
        abstract: {},
        bases: {Object { name: 'std::anyscalar' }},
        ancestors: {Object { name: 'std::anyscalar' }},
        annotations: {},
        constraints: {}
    }
}

For an enumerated scalar type, consider the following:

Copy
scalar type Color extending enum<Red, Green, Blue>;

Introspection of the enum scalar Color:

Copy
db> 
... 
... 
... 
... 
... 
... 
... 
... 
... 
... 
... 
with module schema
select ScalarType {
    name,
    default,
    enum_values,
    abstract,
    bases: { name },
    ancestors: { name },
    annotations: { name, @value },
    constraints: { name },
}
filter .name = 'default::Color';
{
    Object {
        name: 'default::Color',
        default: {},
        enum_values: ['Red', 'Green', 'Blue'],
        abstract: {},
        bases: {Object { name: 'std::anyenum' }},
        ancestors: {
            Object { name: 'std::anyscalar' },
            Object { name: 'std::anyenum' }
        },
        annotations: {},
        constraints: {}
    }
}