import { gql, actionPromise } from "./index";

export const updateProfileNickname = (userId, nickname) =>
actionPromise(
  gql(
    `mutation updateUserProfile($user:UserInput){
      UserUpsert(user:$user){
        login
      }
    }`,
    {
      user:{
        _id : userId,
        login: nickname
      }
    }
  )
)


export const updatePost = (postId, title, text) =>{
    actionPromise(
        gql(
            `mutation updatePostTitle($post:PostInput){
                PostUpsert(post:$post){
                    title,
                    text
                }
            }`,
            {
                post:{
                    _id:postId,
                    title: title,
                    text:text
                }
            }
        )
    )
}
