import { ModuleContext } from '@graphql-modules/core' ; import { AccountsMagicLink , RequestMagicLinkEmailErrors } from '@accounts/magic-link' ; import { AccountsServer , AccountsJsError } from '@accounts/server' ; import { AccountsModuleContext } from '../../accounts' ; import { MutationResolvers } from '../../../models' ; export const Mutation = { requestMagicLinkEmail : async ( _ , { email } , { injector } ) => { const accountsServer = injector . get ( AccountsServer ) ; const accountsMagicLink = injector . get ( AccountsMagicLink ) ; try { await accountsMagicLink . requestMagicLinkEmail ( email ) ; } catch ( error ) { if ( accountsServer . options . ambiguousErrorMessages && error instanceof AccountsJsError && error . code === RequestMagicLinkEmailErrors . UserNotFound ) { return null ; } throw error ; } return null ; } , } ;