using Application; using Application.Interfaces.Services; using Application.Services; using Domain.Entities; using GraphQLTEST.GraphQL.Subscriptions; using HotChocolate.Subscriptions; namespace GraphQLTEST.GraphQL.Mutations; [ExtendObjectType(nameof(MutationType))] public class UserMutations { public async Task AddUser(string username, string email, string password, [Service] IUserService service) => await Task.Run(() => service.CreateUser(username, password, email)); public async Task AddKill( string victim, double damage, int userId, [Service] IKillService killService, [Service] IUserService userService, [Service] ITopicEventSender eventSender, CancellationToken cancellationToken) { var user = userService.GetUserById(userId); var kill = new Kill { Id = Random.Shared.Next(0, 100), Damage = damage, User = user, UserId = user.Id, Victim = victim }; killService.AddKill(kill); await eventSender.SendAsync(nameof(UserSubscriptions.KillAdded), kill, cancellationToken); return kill; } }