Class EdgeCountTrait

EdgeCountTrait computes the count of edges to/from a vertex and stores the result as a property on the vertex.

The value of the computed property will also be indexed for Search.

! The trait has limitations - you can check them out here https://github.com/invotra/kosmos/pull/1926.

Usage:

traits:
- type: edge_count
fields:
membersCount:
- searchField: members
vertex:
- User
nonZeroTagsCount:
- searchField: tags
exclude:
- property: weight
value: 0

Hierarchy

Constructors

Properties

Trait instance configuration.

_global: boolean = false

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

_type?: "edge_count"

Trait type.

dataSourceWrapper: DataSourceWrapper
entityLoader: EntityLoader<Record<string, any>>
graphqlSchemaManager: GraphQLSchemaManager
search: Search

Methods

  • Execute search and ignore errors.

    Parameters

    • body: any
    • size: number = 0

    Returns Promise<null | ApiResponse<Record<string, any>, unknown>>

  • 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 is used to hook in the field change to the vertex that the EdgeCountTrait has been attached to.

    Returns

    Parameters

    • schemaString: string

    Returns string

Generated using TypeDoc