import { useMutation } from '@vue/apollo-composable'
import gql from 'graphql-tag'

export const useEmailService = function(){

  const {mutate: send, onError, onDone: onSent, loading: loadingMutation } = useMutation(gql`
      mutation send_email($mdl: String!, $ref_id: String!, $email_from_name: String!, $email_to: String!, $email_cc: String!, $email_bcc: String!, $email_subject: String!, $email_body: String!, $email_attachments: [Upload]!) {
        send_email(mdl: $mdl, ref_id: $ref_id, email_from_name: $email_from_name, email_to: $email_to, email_cc: $email_cc, email_bcc: $email_bcc, email_subject: $email_subject, email_body: $email_body, email_attachments: $email_attachments) {
          email{
            node_description
          }
        }
      }
    `, { refetchQueries : ['get_email_sent_set']})


  return {send, onError, onSent, loadingMutation}

}
