ποΈDelete a Message
This is the GraphQL mutation to run when you want to delete a message from a mailbox.
Last updated
curl --request POST \
--header 'content-type: application/json' \
--url https://api.maildrop.cc/graphql \
--data '{"query":"mutation Example { delete(mailbox:\"testing\", id:\"abc123\") }"}'{"data":{"delete":true}}export const DELETE_MESSAGE = gql`
mutation DeleteMessage($mailbox: String!, $id: String!) {
delete(mailbox: $mailbox, id: $id)
}
}`;
interface MutationReturn {
delete: boolean;
}
interface MutationVariables {
mailbox: string;
id: string;
}
interface MyComponentProps {
mailbox: string;
id: string;
}
const MyComponent = (props: MyComponentProps) => {
const [deleteMessage, { data, loading, error }] = useMutation<MutationReturn, MutationVariables>(DELETE_MESSAGE, {
variables: { mailbox: props.mailbox, id: props.id }
});
return (
<div>
{loading && <div>Deleting...</div>}
{!loading && <button onClick={deleteMessage}>Delete Message</button>}
{!loading && error && <div>There was an error.</div>}
{!loading && data?.delete && <div>Message deleted.</div>}
</div>
);
};