From fd6c35d08466910f4cddf170f78d9ef464b14e03 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 2 Jul 2024 18:01:02 +0200 Subject: [PATCH] fix(backend): await for events to be written (#1266) await for events to be written to database before returning in resolver --- backend/src/graphql/resolvers/ContactFormResolver.ts | 6 ++++-- .../src/graphql/resolvers/NewsletterSubscriptionResolver.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/resolvers/ContactFormResolver.ts b/backend/src/graphql/resolvers/ContactFormResolver.ts index d9d3b4bc18..6fcdd3d6db 100644 --- a/backend/src/graphql/resolvers/ContactFormResolver.ts +++ b/backend/src/graphql/resolvers/ContactFormResolver.ts @@ -7,9 +7,11 @@ import { EVENT_CONTACTFORM_SEND } from '#src/event/Events' @Resolver() export class ContactFormResolver { @Mutation(() => Boolean) - createContactForm(@Arg('contactFormData') contactFormData: ContactFormInput): boolean { + async createContactForm( + @Arg('contactFormData') contactFormData: ContactFormInput, + ): Promise { void sendContactEmails(contactFormData) - void EVENT_CONTACTFORM_SEND(contactFormData.email) + await EVENT_CONTACTFORM_SEND(contactFormData.email) return true } } diff --git a/backend/src/graphql/resolvers/NewsletterSubscriptionResolver.ts b/backend/src/graphql/resolvers/NewsletterSubscriptionResolver.ts index a073d69deb..7ad2a13c2e 100644 --- a/backend/src/graphql/resolvers/NewsletterSubscriptionResolver.ts +++ b/backend/src/graphql/resolvers/NewsletterSubscriptionResolver.ts @@ -15,14 +15,14 @@ export class NewsletterSubscriptionResolver { subscribeToNewsletterData.lastName, subscribeToNewsletterData.email, ) - void EVENT_NEWSLETTER_SUBSCRIBE(subscribeToNewsletterData.email) + await EVENT_NEWSLETTER_SUBSCRIBE(subscribeToNewsletterData.email) return result } @Mutation(() => Boolean) async confirmNewsletter(@Arg('code') code: string): Promise { const result = await confirmNewsletter(code) - void EVENT_NEWSLETTER_CONFIRM(result ? result.email : undefined) + await EVENT_NEWSLETTER_CONFIRM(result ? result.email : undefined) return !!result } }