mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 00:22:40 +01:00
Fix UpdatedUserTransformer not using projections
This commit is contained in:
@@ -11,9 +11,14 @@ namespace Tgstation.Server.Host.GraphQL.Transformers
|
||||
/// Initializes a new instance of the <see cref="UpdatedUserTransformer"/> class.
|
||||
/// </summary>
|
||||
public UpdatedUserTransformer()
|
||||
: base(model => model.User != null
|
||||
? new UpdatedUser(model.User)
|
||||
: new UpdatedUser(model.Id))
|
||||
: base(
|
||||
BuildSubProjection<Models.User, User, UserTransformer>(
|
||||
(model, user) => new UpdatedUser
|
||||
{
|
||||
Id = model.Id,
|
||||
User = user,
|
||||
},
|
||||
model => model.User))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
|
||||
using HotChocolate.Types.Relay;
|
||||
|
||||
using Tgstation.Server.Host.GraphQL.Transformers;
|
||||
using Tgstation.Server.Host.Models;
|
||||
using HotChocolate.Types.Relay;
|
||||
|
||||
namespace Tgstation.Server.Host.GraphQL.Types
|
||||
{
|
||||
@@ -16,30 +11,11 @@ namespace Tgstation.Server.Host.GraphQL.Types
|
||||
/// The <see cref="User"/>'s <see cref="Entity.Id"/>.
|
||||
/// </summary>
|
||||
[ID(nameof(Types.User))]
|
||||
public long Id { get; }
|
||||
public required long Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Types.User"/>, if was authorized to be read.
|
||||
/// </summary>
|
||||
public User? User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdatedUser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="user">The value of <see cref="User"/> containing the <see cref="Id"/>.</param>
|
||||
public UpdatedUser(Models.User user)
|
||||
: this((user ?? throw new ArgumentNullException(nameof(user))).Require(u => u.Id))
|
||||
{
|
||||
User = ((IApiTransformable<Models.User, User, UserTransformer>)user).ToApi();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdatedUser"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The value of <see cref="Id"/>.</param>
|
||||
public UpdatedUser(long id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
public required User? User { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user