Class MembershipTrait

The membership trait is used to add additional membership functionality to a Vertex, when the trait is added it connects a new entityMembership vertex to the Entity via a hasMembership edge. This entity hold any data required by the membership trait.

Notes:

  • A users membership denoted by the memberOf relationship/edge is added to the entity the trait is added to rather than the entityMembership.

A user can access the following functionality (depending on permissions):

Queries:

  • listInvites : list all outstanding invites the user has made
  • listMembers : list all outstanding invites the user has made

Mutations:

  • accept : accept invitation
  • reject : reject invitation
  • leave : leave a membership
  • invite : create a new invitation
  • remove : remove a membership
  • access : update membership type (hidden/visible)
  • updateRole : update

accept and reject actions are only accessible if user (or invited entity) is not a member.

Permissions for other actions are:

Viewer Editor Manager
List members Yes Yes Yes
Leave Yes Yes Yes
Invite Yes
Remove member Yes
Update membership type Yes
Update membership role Yes

Usage:

traits:
- type: membership # Trait type
# Optional: invitations configuration override.
# Only applies to active memberships.
invite:
type: Invitation # Invitation entity type.
entityTitleField: title # Optional: the entity's field used for the title
entityOwnerEdge: hasManual # Optional: path to the owning entity
entityOwnerType: Organisation # Optional: the type of the owning entity
entityOwnerConnection: memberOf
# Optional: a list of entity types which could be invited, defaults to User.
# Only applies to active memberships.
invitee_types:
- User
- Team
roles: # Optional: roles configuration override.
defaults: # Default roles overrides.
creator: superman # Assign default role to entity creator.
Required if roles are overridden.
member: batman # Assign default role to new members.
Required if roles are overridden.
roles:
- name: superman # Role name.
permissions: # The list of role permissions (MembershipAction type).
- leave
- invite
- remove
- name: batman
permissions:
- leave

Default roles are Viewer, Editor and Manager.

Passive membership configuration example:

traits:
- type: membership
passive: true

Roles can be still configured for passive memberships in case you want to define a different default role for a creator, like an owner instead of a manager. invite and invitee_types are not configurable; adding configs for them will produce an error.

Hierarchy

Constructors

Properties

Trait instance configuration.

_global: boolean = false

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

_type?: "membership"

Trait type.

Methods

  • 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