createDirectChat
talawa-api • Docs
talawa-api / resolvers/Mutation/createDirectChat / createDirectChat
Variable: createDirectChat
> const
createDirectChat: MutationResolvers
["createDirectChat"
]
Creates a new direct chat and associates it with an organization.
This resolver performs the following steps:
- Retrieves the organization based on the provided
organizationId
. - Checks if the organization exists, either from cache or database.
- Validates that all user IDs provided in
userIds
exist. - Creates a new direct chat with the specified users and organization.
Param
The parent object, not used in this resolver.
Param
The input arguments for the mutation, including:
data
: An object containing:organizationId
: The ID of the organization to associate with the direct chat.userIds
: An array of user IDs to be included in the direct chat.
Param
The context object containing user information (context.userId).
Returns
A promise that resolves to the created direct chat object.
Remarks
This function includes caching operations to optimize data retrieval and ensures that all user IDs are valid before creating the direct chat.