From e8499079d90b6b2b88aac16fec4bdef2a1b26ae1 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Fri, 3 Jan 2020 16:49:51 +0100 Subject: [PATCH] Fixed bug "deletePost doesn't work" --- src/graphql/resolvers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graphql/resolvers.ts b/src/graphql/resolvers.ts index af83dcd..fceba25 100644 --- a/src/graphql/resolvers.ts +++ b/src/graphql/resolvers.ts @@ -241,7 +241,10 @@ export function resolver(req: any, res: any): any { }, async deletePost({postId}: { postId: number }) { if (postId) { - const post = await models.Post.findByPk(postId, {include: [models.User]}); + const post = await models.Post.findByPk(postId, {include: [{ + as: "rAuthor", + model: models.User, + }]}); if (post.rAuthor.id === req.session.userId) { return await dataaccess.deletePost(post.id); } else {