Class InboxTrait

Inbox Trait adds global GraphQL Inbox query field listing user's notifications.

Usage:

traits:
- type: inbox
sources:
- User

The 'sources' configuration option specifies which entity types may be be referenced by an inbox notification. These will be used to build the NotificationSource union type. If omitted, the entity type to which the trait is attached will be used (normally this should be the User entity).

Hierarchy

Implements

Constructors

Properties

Trait instance configuration.

_global: boolean = false

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

_relationship?: null | object
_type?: "inbox"

Trait type.

dataSourceWrapper: DataSourceWrapper
graphqlSchemaManager: GraphQLSchemaManager
logger: Logger
schemaManager: SchemaManager
tableName: string

Methods

  • GraphQL resolver to get an entity object from the entity_id and entity_type properties.

    Parameters

    Returns Promise<ItemWithId | {
        id: string;
        label: string;
    }>

  • GraphQL resolver to list the user's inbox messages.

    Parameters

    Returns Promise<InboxGraphQLResult>

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

    Returns

    The GraphQL schema string, including our additions.

    Parameters

    • schemaString: string

      The original GraphQL schema string.

    Returns string

  • Use the preDelete hook to clean up the deleted user's inbox from DynamoDB.

    Todo

    Implement this.

    Parameters

    • data: TraitDataObject<unknown, Record<string, any>, Promise<any>>

      Used by traits for non user accessible entities

    • uuid: string

      The UUID of vertex being deleted.

    • datasourceWrapper: DataSourceWrapper

      Datasource wrapper object.

    • context: KosmosUserContext<object>

      The context of the user on whose behalf the call is being made.

    Returns Promise<void>

  • 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 retrieve additions to the GraphQL schema and to register the callbacks associated to the Vertex.

    Returns

    • GraphQL schema with trait schema appended.

    Parameters

    • schemaString: string

      Existing GraphQL schema.

    • _source: string

      String name of the source vertex that the trait is connected to (not used here)

    • Optional relationship: null | object

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

    Returns string

  • GraphQL mutation resolver to mark a message as read or unread.

    Since the read status is indexed in the partition key, we can't simply overwrite the data.status property in place - we must write a new record and delete the old one.

    Parameters

    Returns Promise<boolean>

Generated using TypeDoc