CRUDSchemaField
@default
Using the @default directive you can specify a default value for the field.
The default value is applied if:
- the event does not contain a payload field with the same name as the field that uses the directive AND
- no other directive produces data for that field AND
- the field that the directive is applied on is not nullable
All three conditions must be met for the default value to be applied.
Example
type User @crudType {
name: String! @default(value: "John Doe")
friends: [String!]! @default(value: ["Jane Doe", "Max Mustermann"])
}In this case, the name field will default to "John Doe" and the friends field will default to ["Jane Doe", "Max Mustermann"].
Limitations of the @default directive
The default directive cannot be used on fields that reference to other projections or CRUD types.