initial commit

This commit is contained in:
Yui
2025-11-26 16:50:06 -03:00
commit 5644aa0ebf
47 changed files with 800 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
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<bool> AddUser(string username, string email, string password, [Service] IUserService service) =>
await Task.Run(() => service.CreateUser(username, password, email));
public async Task<Kill> 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;
}
}