Class ConnectionTrait

The Connection Trait is used to allow an edge the ability to add GraphQL mutation methods to an entity to add and remove connection between defined vertices.

Usage:

traits:
- type: connection
unique: true # optional

Hierarchy

Constructors

Properties

Trait instance configuration.

_dataSourceWrapper: DataSourceWrapper
_global: boolean = false

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

_graphQlSchemaManager: GraphQLSchemaManager
_properties: Record<string, SchemaItemProperty | SchemaItemArrayProperty> = {}
_relationships: Record<string, {
    relationship: VertexRelationship;
    source: string;
}> = {}
_schemaManager: SchemaManager
_type?: "connection"

Trait type.

_unique?: boolean

Used to define if the user can only create a single connection between the source and dest vertices. Here we default to false. An example use case would be for like connections where a user can only like a post once.

accessControl: AccessControl

Methods

  • This method which has been registered using the addMutationHandler() will be called from the super.process(), when the trait has been activated a connection will be created between the src and destination vertices.

    Parameters

    Returns Promise<boolean>

  • This is where any GraphQL mutation entries that are rquired by the trait are added.

    Returns

    Returns graphql schema segment for inclusion in main graphql doc.

    Parameters

    • schemaString: string
    • source: string

      String name of the source vertex that the trait is connected to

    • Optional relationship: null | VertexRelationship

      JSON Object of the relationship, can be null where trait is not attached to a relationship.

    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>

  • This method which has been registered using the addMutationHandler() will be called from the super.process() when the trait has been activated the connection will be deleted is the user has valid access rights.

    Parameters

    Returns Promise<boolean>

Generated using TypeDoc