createGroupChat method

Future<ChatMixin> createGroupChat(
  1. List<UserId> memberIds, {
  2. ChatName? name,
})

Creates a Chat-group with the provided Users as members and the authenticated MyUser.

There can be many Chat-group between the same Users.

Implementation

Future<ChatMixin> createGroupChat(
  List<UserId> memberIds, {
  ChatName? name,
}) async {
  Log.debug('createGroupChat($memberIds, $name)', '$runtimeType');

  final variables = CreateGroupChatArguments(
    memberIds: memberIds,
    name: name,
  );
  final QueryResult result = await client.mutate(
    MutationOptions(
      operationName: 'CreateGroupChat',
      document: CreateGroupChatMutation(variables: variables).document,
      variables: variables.toJson(),
    ),
    onException:
        (data) => CreateGroupChatException(
          (CreateGroupChat$Mutation.fromJson(data).createGroupChat
                  as CreateGroupChat$Mutation$CreateGroupChat$CreateGroupChatError)
              .code,
        ),
  );
  return (CreateGroupChat$Mutation.fromJson(result.data!).createGroupChat
      as CreateGroupChat$Mutation$CreateGroupChat$Chat);
}