import actionPromise from "./action-promise"
import { gql } from '../../graphQl/getGQL'

export const actionCreateChat = (title, members, chatId, membersId) =>
   actionPromise(
      'updateChat',
      gql(
         `mutation updateChat($chat:ChatInput) {
      ChatUpsert(chat:$chat) {
         _id
         title
         avatar {
            _id
            url
         }
         owner {
            _id
            login
            avatar {
               _id
               url
            }
         }
         members {
            _id
            login
            nick
            avatar {
               _id
               url
            }
         }
         lastModified    
      }
   }`,
         // { chat: { _id: chatId, title, members }, members: {_id: userId} }
         { chat: { title: title, members: {_id: members}} }
      )
   )