import { Arg, Mutation, Resolver } from 'type-graphql'; import { v4 } from 'uuid'; import { Hunt } from '../../entities'; import { AddHuntInput, MutationResponse } from './types'; @Resolver(Hunt) export class HuntResolver { @Mutation(() => MutationResponse) async addHunt( @Arg('input') input: AddHuntInput ): Promise { const { url, email } = input; const id = v4(); const hunt = await Hunt.create({ id, firebaseId: id, url, email, }).save(); return { hunt, success: true, }; } }