From 3eb635bb2e0cd50dca1ca993ccee36ec8451eeff Mon Sep 17 00:00:00 2001 From: Sendou Date: Sun, 15 Dec 2019 16:51:00 +0200 Subject: [PATCH] using promise all in addFreeAgentPost resolver --- schemas/fapost.js | 6 ++---- utils/webhook.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/schemas/fapost.js b/schemas/fapost.js index 8f8030525..a35ad3b47 100644 --- a/schemas/fapost.js +++ b/schemas/fapost.js @@ -143,16 +143,14 @@ const resolvers = { } const faPost = new FAPost({ ...args, discord_id: ctx.user.discord_id }) - await faPost.save().catch(e => { + args.user = ctx.user + await Promise.all([faPost.save(), sendFAPostToDiscord(args)]).catch(e => { throw (new UserInputError(), { invalidArgs: args, }) }) - args.user = ctx.user - sendFAPostToDiscord(args) - return true }, updateFreeAgentPost: async (root, args, ctx) => { diff --git a/utils/webhook.js b/utils/webhook.js index 72c477d13..40e146217 100644 --- a/utils/webhook.js +++ b/utils/webhook.js @@ -51,7 +51,7 @@ function sendFAPostToDiscord(args) { ) } - return Hook.send(msg) + return () => Hook.send(msg) } module.exports = sendFAPostToDiscord