Introduction
Documentation of the CRUD service schema definition.
A CRUD Type can be defined by a GraphQL schema:
type User @crudType {
name: String!
}
This CRUD type will create several projections in the database, accessible via the GraphQL API: The name of the projection equals the name of the type in the schema. The name will be part of the corresponding queries and subscriptions in the GraphQL API, too.
Object Directives
The following directives can be applied to the whole CRUD type:
Directive | Description |
---|---|
@crudType | An object type on which data can be created, read, updated, deleted |
@expires | Automatically remove data after expiration |
@filterByJwtData | Filter data based on a field in the JWT |
@global | Crud types over all tenants |
@permission | Restrict access permissions on the crud type |
@renamed | Rename a crud type |
@unique | Unique constraints on multiple fields |
Fields
Supported field types:
- String
- ID
- Boolean
- Int
- Float
- DateTime (unix timestamp, milliseconds)
- Enums
- Objects / references to other crud or CRUD types
- Arrays of all types listed above
- All types listed above in their required form
[EventEnvelope!]!
Event Envelope
The field type [EventEnvelope!]!
is a special field type that can only be used in this form at
the root level of a projection (not in a nested object). It will automatically aggregate all
events that are applied on the projection entry into an array. Use the type in conjunction with
the @aggregateEvents
directive. This is very useful for debugging.
Every projection will automatically get three fields:
Field | Type | Description |
---|---|---|
id | ID! | The identifier of the projection |
createdAt | DateTime! | The creation time of the entry |
changedAt | DateTime! | The time of the last change of the entry |
By default the value of a field equals the value of the event payload field that has the exact same name.
Required fields are marked by an !
, e.g. String!
.
Fields with the !
flag will default to their zero value (""
for strings, 0
for numbers, false
for booleans, []
for arrays).
Field Directives
By default the value of a field equals the value of the event payload field that has the exact same name. This behavior can be changed by using directives on a field level:
Directive | Description |
---|---|
@changedBy | Reflects the user that has last changed the entry |
@cloneField | Clone a field to another field |
@createdBy | Reflects the user that has created the entry |
@default | Set a default value |
@gdpr | Apply GDPR logic on a field |
@index | Make a field filterable ans sortable |
@immutable | Mark a field as immutable |
@permission | Restrict access permissions on the field |
@readonly | Make a field read-only |
@renamed | Rename a crud type field |
@safeHtml | Sanitize html strings |
@sequence | Automated sequence generator |
@unique | Make a field unique |
@validate | Validate field data |