Protected Optional _configTrait instance configuration.
Protected Readonly _dataProtected Readonly _externalProtected _globalWhether this is a global (not bound to any specific schema item) trait instance.
Protected Readonly _graphqlProtected Readonly _jsonProtected _mutationProtected _retainProtected Readonly _schemaProtected _storageProtected Optional _typeTrait type.
Protected Readonly _validatorHelper method which initializes/returns JsonContentTrait storage object.
The trait data object
Attaches Trait callbacks to schema item hooks.
This function handles the filtering and deserialisation of the json field
Rest ...traitData: [datasourceWrapper: DataSourceWrapper, data: TraitDataObject<any, any, Promise<any>>]The trait data object
Utility function used to load and entity by id.
The entity object or NULL.
The trait data object.
Private loadReturns schemas for every JSON field of entity
Optional data: Record<string, any>Optional originalItem: null | EntityObjectMakes this Trait instance global.
Add mutation to enable the JSON field to be updated.
GraphQL schema segment for inclusion in main graphql doc.
The existing schema string.
String name of the source vertex that the trait is connected to.
After the Vertex has been created make sure to attach it to the schema
The trait data object
The item being created
Datasource wrapper object.
The user context.
Called after vertex is updated.
Used by traits for non user accessible entities
The item being updated.
Pre add relationship hook implementation.
Validate new relation
The trait data object
The data to update.
Datasource wrapper object; not used.
The user context.
Before the entity is created check if a schema is being defined that it exists and is available to the user.
The trait data.
Datasource wrapper object.
The user context.
Pre remove relationship hook implementation.
Validate relation to remove
The trait data object
The data to update.
Datasource wrapper object; not used.
The user context.
Pre-update hook implementation.
Validate new schema for JSON field if it was changed
The trait data object
The data to update.
Datasource wrapper object; not used.
The user context.
This method is triggered when a trait callback has been activated
This is the name of the callback function to call.
References to the Graph Hanlder
Request data passed along as part of the request.
Utility function used to save a json entity to storage.
Boolean indication if saving was successful.
The trait data object.
The json data to be stored.
Private selectReturns list of relations for entity based on schemas
list of schemas for entity
Configuration setter.
The new configuration.
This function handles updating json fields. Most likely will be deprecated soon.
Rest ...traitData: [datasourceWrapper: DataSourceWrapper, data: TraitDataObject<any, any, Promise<any>>]The trait data object
Private validateThrows error when query arguments contain forbidden relations
list of disabled relations
This function is used to validate json which has been string encoded against a defined schema.
The users context
Private validateThrows error when query arguments contain forbidden relations or don't contain required
user context
Private validateThrows error when query arguments contain forbidden relations
item to update
trait data
user context
Throws error when relation isn't valid
relation to create / remove
entity type to validate
entity id to validate
action with edge
user context
Private validateThrows error when query arguments don't contain all required relations
Helper method for wrapping legacy Kosmos traits callbacks.
TODO: Remove this method once all Traits are converted.
Optional callbackName: stringOptional callback name; passing this parameter will additionally wrap the callback into legacy process().
Static traitGenerated using TypeDoc
The JsonContentTrait is used to enable adding multiple json fields to an entity. A schema vertex must be defined along with the property which is used as the name of the schema.
For each field a name must be defined and optionally a type which is used to hold the name of the applied schema if ones is defined. If one is not defined the field will not be validated against a schema.
Usage: