I'm fetching emails from IMAP and want to store them in PostgreSQL via Hasura GraphQL API. As HTML and special characters can't be in the valid GraphQL query, I need to get rid of them. Remove or replace with something acceptable. That ends up with ugly and unformatted content in the DB. Googled but can't really find a good or at least near-perfect solution for getting the most readable (ideally lossless) content in PostgreSQL.
I have to create an admin panel where emails can be assigned to users and have other relations and different rights (eg. one role won't see email addresses and possible phone numbers and other contacts removed from the email content). But they can reply from the system. Everything is easy except the question of how to get the modified HTML email to the DB.
Maybe I shouldn't use GraphQL. Maybe not JavaScript. I can code in PHP, too if that's easier but I prefer JavaScript as I use N8N.io workflow and I can easily use JavaScript there. Option I was also considering is to use PostgreSQL compression but then I can not use the Directus.io admin panel (that is used) for viewing, editing and adding relations to the emails.