Using metadata to store html comment

This commit is contained in:
okbel
2018-02-21 16:59:02 -03:00
parent bf1bae8999
commit 38352e9e3c
2 changed files with 8 additions and 7 deletions
+7 -4
View File
@@ -1,12 +1,15 @@
const TurndownService = require('turndown');
const { merge } = require('lodash');
module.exports = {
RootMutation: {
createComment: {
async pre(_, { input }, _context, _info) {
// Saving the HTML comment as Markdown
const ts = new TurndownService();
input.body = ts.turndown(input.body);
input.metadata = merge(
{},
{
htmlBody: input.htmlBody,
}
);
},
},
},
+1 -3
View File
@@ -1,7 +1,5 @@
const marked = require('marked');
module.exports = {
Comment: {
body: comment => marked(comment.body),
htmlBody: comment => comment.metadata.htmlBody,
},
};