
mutation createConversation(
  $subject: String
  $status: ConversationStatus
  $conversationType: ConversationType
  $isGroup: Boolean
  $groupName: String
  $lastMessage: String
  $lastMessageAt: Timestamp
) @auth(level: USER) {
  conversation_insert(
    data: {
      subject: $subject
      status: $status
      conversationType: $conversationType
      isGroup: $isGroup
      groupName: $groupName
      lastMessage: $lastMessage
      lastMessageAt: $lastMessageAt
    }
  )
}

mutation updateConversation(
  $id: UUID!

  $subject: String
  $status: ConversationStatus
  $conversationType: ConversationType
  $isGroup: Boolean
  $groupName: String
  $lastMessage: String
  $lastMessageAt: Timestamp
  
) @auth(level: USER) {
  conversation_update(
    id: $id
    data: {
      subject: $subject
      status: $status
      conversationType: $conversationType
      isGroup: $isGroup
      groupName: $groupName
      lastMessage: $lastMessage
      lastMessageAt: $lastMessageAt
    }
  )
}

# ----------------------------------------------------------
# UPDATE LAST MESSAGE 
# ----------------------------------------------------------
mutation updateConversationLastMessage(
  $id: UUID!
  $lastMessage: String
  $lastMessageAt: Timestamp
) @auth(level: USER) {
  conversation_update(
    id: $id
    data: {
      lastMessage: $lastMessage
      lastMessageAt: $lastMessageAt
    }
  )
}

mutation deleteConversation($id: UUID!) @auth(level: USER) {
  conversation_delete(id: $id)
}
