abstract class BaseNodePropertyDelegate<T : Node?, R>(parent: Node, property: KProperty1<*, *>) : PropertyDelegate<NodeQueryResult<T & Any>>

Base class for many and one node property delegates Provides cache based GraphQL functionality, and abstract methods with allow persistence

Parameters

parent

the node which hosts this property

property

the property on the class

Type Parameters

T

the type of the value Node (s)

R

the type of property

Inheritors

Constructors

Link copied to clipboard
constructor(parent: Node, property: KProperty1<*, *>)

Properties

Link copied to clipboard

Delegate for lazy-loading the property

Link copied to clipboard
protected var nodeCache: NodeCache?

NodeCache used to load this property might be set after initial loading, but must not be changed

Link copied to clipboard
protected val parent: Node
Link copied to clipboard
protected val property: KProperty1<*, *>
Link copied to clipboard
protected val propertyName: String

Dynamic type of parent and name of property, can be used for error messages without leaking information

Functions

Link copied to clipboard
internal abstract suspend fun getLoadedProperty(cache: NodeCache?, loader: LazyLoadingSubqueryGenerator<T>.() -> Unit?): R

Gets the loaded property which is returned by the lazy loading delegate

Link copied to clipboard
internal abstract fun getLoadedRelatedNodes(): Collection<Node>

Gets related nodes defined by this property, but only those already loaded (therefore no lazy loading) The relationships do not have to be persisted yet

Link copied to clipboard
internal abstract fun getRelatedNodesToSave(): Collection<Node>

Gets Nodes which should be persisted when this Node is persisted

Link copied to clipboard
internal abstract fun getRelationshipDiff(): RelationshipDiff

Gets the diff of added and removed relationships to persist in the database

Link copied to clipboard
operator fun getValue(thisRef: Node, property: KProperty<*>): LazyLoadingDelegate<T, R>

Gets the lazy loading delegate which is used to get the value of the property

Link copied to clipboard
open override fun registerQueryResult(fieldDefinition: FieldDefinition, queryResult: NodeQueryResult<T & Any>)

Called to register a database query result Adds the result to the cache Can be overridden to add custom behavior (super should be called in this case)

Link copied to clipboard
abstract fun validate(savingNodes: Set<Node>, relationshipDefinition: RelationshipDefinition, nodeDefinitionCollection: NodeDefinitionCollection)

Called to validate the property Should throw an exception if the property is invalid, with an appropriate reason