From bd56a39d73af12aeeb0ace2dbb77df40d5e12ef1 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 25 Sep 2018 10:06:05 -0600 Subject: [PATCH] review: fixes --- src/core/server/models/comment.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/server/models/comment.ts b/src/core/server/models/comment.ts index a780b24ad..18c7b8cf7 100644 --- a/src/core/server/models/comment.ts +++ b/src/core/server/models/comment.ts @@ -370,16 +370,20 @@ export async function retrieveCommentParentsConnection( // Loop over the list to ensure that none of the entries is null (indicating // that there was a misplaced parent). We can assert the type here because we // will throw an error and abort if one of the comments are null. - const nodes = parents.filter(parentComment => { + parents.forEach(parentComment => { if (!parentComment) { // TODO: (wyattjoh) replace with a better error. throw new Error("parent id specified does not exist"); } return true; - }) as Array>; + }); - const edges = nodesToEdges(nodes, (_, index) => index + skip + 1).reverse(); + const edges = nodesToEdges( + // We can't have a null parent after the forEach filter above. + parents as Array>, + (_, index) => index + skip + 1 + ).reverse(); // Return the resolved connection. return {