Class LockingTrait

The Locking Trait is used to lock entity update mutations. Lock allows to handle that this document will not be edited by 2 users Lock can be acquired by mutation Lock can be broken by mutation and after updating entity

This trait adds new properties to query resolver:

  1. lockedBy - user that made this lock
  2. locked - locked flag
  3. lockedTimestamp - lock creation time

To prolong lock after update mutation there is keepTheLock flag in arguments ACL for breaking the lock by another user can be defined via policies: Entity:ForceBreakLock

Usage:

traits:
- type: locking
lock_time: 15m

Hierarchy

Constructors

Properties

Trait instance configuration.

_global: boolean = false

Whether this is a global (not bound to any specific schema item) trait instance.

_type?: "locking"

Trait type.

accessControl: AccessControl
attachToEntities: LockingConfigAttachSetting[] = []
dataSourceWrapper: DataSourceWrapper
dynamicConfigValidationRequired: boolean = false
graphqlSchemaManager: GraphQLSchemaManager
lockManager: LockManager
lockTimeSeconds: number = DEFAULT_LOCK_TIME_SECONDS
pathToAttachedEntity: string = ''
hookedIntoAccessControl: boolean = false

Methods

  • Creates locking configs and attaches entities to created configs. If config has already created but entity is not attached - adds required edge

    Parameters

    • vertices: LoadedEntities[]
    • data: TraitDataObject<unknown, Record<string, any>, Promise<any>>

    Returns Promise<void>

  • Generates lock timestamp based on ttl value

    Parameters

    • ttl: number

      time to live

    Returns Date

  • Loads entities declared in config using gremlin queries

    Parameters

    Returns Promise<LoadedEntities[]>

  • Loads all existed configs and finds entities without attached configs Fills following properties of vertices[i]:

    1. vertices[i].connectionRequired - entities without attached config
    2. vertices[i].config - existed config for this group of entities

    Parameters

    • vertices: LoadedEntities[]
    • data: TraitDataObject<unknown, Record<string, any>, Promise<any>>

    Returns Promise<void>

  • Parameters

    • query: string
    • label: string
    • mutationType: "update" | "create"

    Returns string

  • This method is triggered when a trait callback has been activated

    Type Parameters

    • RT = any

    • Payload = any

    Parameters

    • callbackName: string

      This is the name of the callback function to call.

    • datasourceWrapper: DataSourceWrapper

      References to the Graph Hanlder

    • data: TraitDataObject<RT, Payload, Promise<any>>

      Request data passed along as part of the request.

    Returns Promise<RT>

Generated using TypeDoc