Move transformers to GraphQL namespace and remove GraphQL from name

This commit is contained in:
Jordan Dominion
2025-08-16 13:39:12 -04:00
parent 05f6303f16
commit a5c3d64fe3
30 changed files with 191 additions and 179 deletions
@@ -15,8 +15,8 @@ using Tgstation.Server.Host.Authority.Core;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.GraphQL.Mutations.Payloads;
using Tgstation.Server.Host.GraphQL.Transformers;
using Tgstation.Server.Host.Models;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.Security;
using Tgstation.Server.Host.Security.OAuth;
using Tgstation.Server.Host.Utils;
@@ -302,7 +302,7 @@ namespace Tgstation.Server.Host.Authority
var payload = new LoginResult
{
Bearer = token,
User = ((IApiTransformable<User, GraphQL.Types.User, UserGraphQLTransformer>)user).ToApi(),
User = ((IApiTransformable<User, GraphQL.Types.User, UserTransformer>)user).ToApi(),
};
if (usingSystemIdentity)
@@ -24,8 +24,8 @@ using Tgstation.Server.Host.Authority.Core;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.GraphQL.Transformers;
using Tgstation.Server.Host.Models;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.Security;
using Tgstation.Server.Host.Security.RightsEvaluation;
@@ -743,7 +743,7 @@ namespace Tgstation.Server.Host.Authority
user.Require(x => x.Id))
.Select(topic => topicEventSender.SendAsync(
topic,
((IApiTransformable<User, GraphQL.Types.User, UserGraphQLTransformer>)user).ToApi(),
((IApiTransformable<User, GraphQL.Types.User, UserTransformer>)user).ToApi(),
CancellationToken.None))); // DCT: Operation should always run
/// <summary>
@@ -8,8 +8,8 @@ using HotChocolate.Types.Relay;
using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.GraphQL.Mutations.Payloads;
using Tgstation.Server.Host.GraphQL.Transformers;
using Tgstation.Server.Host.GraphQL.Types;
using Tgstation.Server.Host.Models.Transformers;
namespace Tgstation.Server.Host.GraphQL.Mutations
{
@@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
ArgumentNullException.ThrowIfNull(name);
ArgumentNullException.ThrowIfNull(userGroupAuthority);
return userGroupAuthority.InvokeTransformable<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(
return userGroupAuthority.InvokeTransformable<Models.UserGroup, UserGroup, UserGroupTransformer>(
authority => authority.Create(name, TransformApiPermissionSet(permissionSet), cancellationToken));
}
@@ -74,7 +74,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userGroupAuthority);
return userGroupAuthority.InvokeTransformable<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(
return userGroupAuthority.InvokeTransformable<Models.UserGroup, UserGroup, UserGroupTransformer>(
authority => authority.Update(id, newName, TransformApiPermissionSet(newPermissionSet), cancellationToken));
}
@@ -11,9 +11,9 @@ using HotChocolate.Types.Relay;
using Tgstation.Server.Api.Models.Request;
using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.GraphQL.Mutations.Payloads;
using Tgstation.Server.Host.GraphQL.Transformers;
using Tgstation.Server.Host.GraphQL.Types;
using Tgstation.Server.Host.GraphQL.Types.OAuth;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.Security;
namespace Tgstation.Server.Host.GraphQL.Mutations
@@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
ArgumentNullException.ThrowIfNull(password);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Create(
new UserCreateRequest
{
@@ -112,7 +112,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
ArgumentNullException.ThrowIfNull(password);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Create(
new UserCreateRequest
{
@@ -167,7 +167,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
ArgumentNullException.ThrowIfNull(oAuthConnections);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Create(
new UserCreateRequest
{
@@ -225,7 +225,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
ArgumentNullException.ThrowIfNull(oAuthConnections);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Create(
new UserCreateRequest
{
@@ -279,7 +279,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
ArgumentNullException.ThrowIfNull(systemIdentifier);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Create(
new UserCreateRequest
{
@@ -335,7 +335,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
ArgumentNullException.ThrowIfNull(systemIdentifier);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Create(
new UserCreateRequest
{
@@ -381,7 +381,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
{
ArgumentNullException.ThrowIfNull(newPassword);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Update(
new UserUpdateRequest
{
@@ -410,7 +410,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
{
ArgumentNullException.ThrowIfNull(newOAuthConnections);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
return userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Update(
new UserUpdateRequest
{
@@ -573,7 +573,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations
IEnumerable<OidcConnection>? newOidcConnections,
IGraphQLAuthorityInvoker<IUserAuthority> userAuthority,
CancellationToken cancellationToken)
=> userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserGraphQLTransformer>(
=> userAuthority.InvokeTransformable<Models.UpdatedUser, UpdatedUser, UpdatedUserTransformer>(
authority => authority.Update(
new UserUpdateRequest
{
@@ -0,0 +1,22 @@
using Tgstation.Server.Host.GraphQL.Types.OAuth;
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="Models.ITransformer{TInput, TOutput}"/> for <see cref="OAuthConnection"/>s.
/// </summary>
sealed class OAuthConnectionTransformer : Models.TransformerBase<Models.OAuthConnection, OAuthConnection>
{
/// <summary>
/// Initializes a new instance of the <see cref="OAuthConnectionTransformer"/> class.
/// </summary>
public OAuthConnectionTransformer()
: base(model => new Types.OAuth.OAuthConnection
{
ExternalUserId = model.ExternalUserId ?? NotNullFallback<string>(),
Provider = model.Provider,
})
{
}
}
}
@@ -0,0 +1,22 @@
using Tgstation.Server.Host.GraphQL.Types.OAuth;
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="Models.ITransformer{TInput, TOutput}"/> for <see cref="OidcConnection"/>s.
/// </summary>
sealed class OidcConnectionTransformer : Models.TransformerBase<Models.OidcConnection, OidcConnection>
{
/// <summary>
/// Initializes a new instance of the <see cref="OidcConnectionTransformer"/> class.
/// </summary>
public OidcConnectionTransformer()
: base(model => new OidcConnection
{
ExternalUserId = model.ExternalUserId ?? NotNullFallback<string>(),
SchemeKey = model.SchemeKey ?? NotNullFallback<string>(),
})
{
}
}
}
@@ -1,26 +1,26 @@
using Tgstation.Server.Api.Rights;
using Tgstation.Server.Host.GraphQL.Types;
namespace Tgstation.Server.Host.Models.Transformers
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="GraphQL.Types.PermissionSet"/>s.
/// <see cref="Models.ITransformer{TInput, TOutput}"/> for <see cref="PermissionSet"/>s.
/// </summary>
sealed class PermissionSetGraphQLTransformer : TransformerBase<PermissionSet, GraphQL.Types.PermissionSet>
sealed class PermissionSetTransformer : Models.TransformerBase<Models.PermissionSet, PermissionSet>
{
/// <summary>
/// Initializes a new instance of the <see cref="PermissionSetGraphQLTransformer"/> class.
/// Initializes a new instance of the <see cref="PermissionSetTransformer"/> class.
/// </summary>
public PermissionSetGraphQLTransformer()
public PermissionSetTransformer()
: base(
BuildSubProjection<
InstanceManagerRights?,
AdministrationRights?,
RightsHolder<InstanceManagerRights>,
RightsHolder<AdministrationRights>,
RightsHolderGraphQLTransformer<InstanceManagerRights>,
RightsHolderGraphQLTransformer<AdministrationRights>>(
(model, instanceManagerRights, administrationRights) => new GraphQL.Types.PermissionSet
RightsHolderTransformer<InstanceManagerRights>,
RightsHolderTransformer<AdministrationRights>>(
(model, instanceManagerRights, administrationRights) => new PermissionSet
{
AdministrationRights = administrationRights ?? NotNullFallback<RightsHolder<AdministrationRights>>(),
InstanceManagerRights = instanceManagerRights ?? NotNullFallback<RightsHolder<InstanceManagerRights>>(),
@@ -1,20 +1,21 @@
using System;
using Tgstation.Server.Host.GraphQL.Types;
using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Models.Transformers
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="RightsHolder{TRight}"/>s.
/// </summary>
/// <typeparam name="TRight">The <see cref="Api.Rights.RightsType"/> of the <see cref="RightsHolder{TRight}"/>.</typeparam>
sealed class RightsHolderGraphQLTransformer<TRight> : TransformerBase<TRight?, RightsHolder<TRight>>
sealed class RightsHolderTransformer<TRight> : TransformerBase<TRight?, RightsHolder<TRight>>
where TRight : struct, Enum
{
/// <summary>
/// Initializes a new instance of the <see cref="RightsHolderGraphQLTransformer{TRight}"/> class.
/// Initializes a new instance of the <see cref="RightsHolderTransformer{TRight}"/> class.
/// </summary>
public RightsHolderGraphQLTransformer()
public RightsHolderTransformer()
: base(right => new RightsHolder<TRight>
{
Right = right ?? NotNullFallback<TRight>(),
@@ -0,0 +1,20 @@
using Tgstation.Server.Host.GraphQL.Types;
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="Models.ITransformer{TInput, TOutput}"/> for <see cref="UpdatedUser"/>s.
/// </summary>
sealed class UpdatedUserTransformer : Models.TransformerBase<Models.UpdatedUser, UpdatedUser>
{
/// <summary>
/// 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))
{
}
}
}
@@ -0,0 +1,26 @@
using Tgstation.Server.Host.GraphQL.Types;
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="Models.ITransformer{TInput, TOutput}"/> for <see cref="Types.UserGroup"/>s.
/// </summary>
sealed class UserGroupTransformer : Models.TransformerBase<Models.UserGroup, UserGroup>
{
/// <summary>
/// Initializes a new instance of the <see cref="UserGroupTransformer"/> class.
/// </summary>
public UserGroupTransformer()
: base(
BuildSubProjection<Models.PermissionSet, PermissionSet, PermissionSetTransformer>(
(model, permissionSet) => new UserGroup
{
Id = model.Id!.Value,
Name = model.Name!,
PermissionSet = permissionSet!,
},
model => model.PermissionSet))
{
}
}
}
@@ -0,0 +1,22 @@
using Tgstation.Server.Host.GraphQL.Types;
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="Models.ITransformer{TInput, TOutput}"/> for <see cref="UserName"/>s.
/// </summary>
sealed class UserNameTransformer : Models.TransformerBase<Models.User, UserName>
{
/// <summary>
/// Initializes a new instance of the <see cref="UserNameTransformer"/> class.
/// </summary>
public UserNameTransformer()
: base(model => new UserName
{
Id = model.Id!.Value,
Name = model.Name!,
})
{
}
}
}
@@ -1,25 +1,27 @@
using System;
namespace Tgstation.Server.Host.Models.Transformers
using Tgstation.Server.Host.GraphQL.Types;
namespace Tgstation.Server.Host.GraphQL.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="GraphQL.Types.User"/>s.
/// <see cref="Models.ITransformer{TInput, TOutput}"/> for <see cref="User"/>s.
/// </summary>
sealed class UserGraphQLTransformer : TransformerBase<User, GraphQL.Types.User>
sealed class UserTransformer : Models.TransformerBase<Models.User, User>
{
/// <summary>
/// Initializes a new instance of the <see cref="UserGraphQLTransformer"/> class.
/// Initializes a new instance of the <see cref="UserTransformer"/> class.
/// </summary>
public UserGraphQLTransformer()
public UserTransformer()
: base(
BuildSubProjection<
Models.UserGroup,
Models.PermissionSet,
UserGroup,
PermissionSet,
GraphQL.Types.UserGroup,
GraphQL.Types.PermissionSet,
UserGroupGraphQLTransformer,
PermissionSetGraphQLTransformer>(
(model, group, ownedPermissionSet) => new GraphQL.Types.User
UserGroupTransformer,
PermissionSetTransformer>(
(model, group, ownedPermissionSet) => new User
{
CreatedAt = model.CreatedAt ?? NotNullFallback<DateTimeOffset>(),
CanonicalName = model.CanonicalName ?? NotNullFallback<string>(),
@@ -29,11 +31,10 @@ namespace Tgstation.Server.Host.Models.Transformers
Name = model.Name ?? NotNullFallback<string>(),
SystemIdentifier = model.SystemIdentifier,
OwnedPermissionSet = ownedPermissionSet,
EffectivePermissionSet = ownedPermissionSet != null
? ownedPermissionSet
: group != null
EffectivePermissionSet = ownedPermissionSet ??
(group != null
? group.PermissionSet
: NotNullFallback<GraphQL.Types.PermissionSet>(),
: NotNullFallback<PermissionSet>()),
Group = group,
},
model => model.Group,
@@ -2,8 +2,8 @@
using HotChocolate.Types.Relay;
using Tgstation.Server.Host.GraphQL.Transformers;
using Tgstation.Server.Host.Models;
using Tgstation.Server.Host.Models.Transformers;
namespace Tgstation.Server.Host.GraphQL.Types
{
@@ -30,7 +30,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
public UpdatedUser(Models.User user)
: this((user ?? throw new ArgumentNullException(nameof(user))).Require(u => u.Id))
{
User = ((IApiTransformable<Models.User, User, UserGraphQLTransformer>)user).ToApi();
User = ((IApiTransformable<Models.User, User, UserTransformer>)user).ToApi();
}
/// <summary>
@@ -16,8 +16,8 @@ using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.Authority.Core;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.GraphQL.Interfaces;
using Tgstation.Server.Host.GraphQL.Transformers;
using Tgstation.Server.Host.GraphQL.Types.OAuth;
using Tgstation.Server.Host.Models.Transformers;
namespace Tgstation.Server.Host.GraphQL.Types
{
@@ -94,7 +94,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
ArgumentNullException.ThrowIfNull(ids);
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.ExecuteDataLoader<Models.User, User, UserGraphQLTransformer>(
return userAuthority.ExecuteDataLoader<Models.User, User, UserTransformer>(
(authority, id) => authority.GetId<User>(id, false, cancellationToken),
ids,
queryContext);
@@ -132,7 +132,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
if (!CreatedById.HasValue)
return null;
var user = await userAuthority.InvokeTransformable<Models.User, User, UserGraphQLTransformer>(authority => authority.GetId(CreatedById.Value, false, true, cancellationToken));
var user = await userAuthority.InvokeTransformable<Models.User, User, UserTransformer>(authority => authority.GetId(CreatedById.Value, false, true, cancellationToken));
if (user.CanonicalName == Models.User.CanonicalizeName(Models.User.TgsSystemUserName))
return new UserName(user);
@@ -154,7 +154,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformableQueryable<Models.OAuthConnection, OAuthConnection, OAuthConnectionGraphQLTransformer>(
return userAuthority.InvokeTransformableQueryable<Models.OAuthConnection, OAuthConnection, OAuthConnectionTransformer>(
authority => authority.OAuthConnections(Id, cancellationToken));
}
@@ -173,7 +173,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformableQueryable<Models.OidcConnection, OidcConnection, OidcConnectionGraphQLTransformer>(
return userAuthority.InvokeTransformableQueryable<Models.OidcConnection, OidcConnection, OidcConnectionTransformer>(
authority => authority.OidcConnections(Id, cancellationToken));
}
}
@@ -7,9 +7,9 @@ using HotChocolate;
using HotChocolate.Data;
using HotChocolate.Types;
using HotChocolate.Types.Relay;
using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.GraphQL.Types
{
@@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userGroupAuthority);
return userGroupAuthority.InvokeTransformableAllowMissing<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(
return userGroupAuthority.InvokeTransformableAllowMissing<Models.UserGroup, UserGroup, UserGroupTransformer>(
authority => authority.GetId(id, false, cancellationToken));
}
@@ -53,7 +53,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
[Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
{
ArgumentNullException.ThrowIfNull(userAuthority);
var dtoQueryable = await userAuthority.InvokeTransformableQueryable<Models.User, User, UserGraphQLTransformer>(
var dtoQueryable = await userAuthority.InvokeTransformableQueryable<Models.User, User, UserTransformer>(
authority => authority
.Queryable(false),
queryable => queryable.Where(user => user.GroupId == Id));
@@ -9,7 +9,7 @@ using HotChocolate.Types;
using HotChocolate.Types.Relay;
using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.GraphQL.Types
{
@@ -29,7 +29,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userGroupAuthority);
return userGroupAuthority.InvokeTransformableAllowMissing<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(authority => authority.Read(cancellationToken));
return userGroupAuthority.InvokeTransformableAllowMissing<Models.UserGroup, UserGroup, UserGroupTransformer>(authority => authority.Read(cancellationToken));
}
/// <summary>
@@ -57,7 +57,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
[Service] IGraphQLAuthorityInvoker<IUserGroupAuthority> userGroupAuthority)
{
ArgumentNullException.ThrowIfNull(userGroupAuthority);
var dtoQueryable = await userGroupAuthority.InvokeTransformableQueryable<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(
var dtoQueryable = await userGroupAuthority.InvokeTransformableQueryable<Models.UserGroup, UserGroup, UserGroupTransformer>(
authority => authority.Queryable(false));
return dtoQueryable;
}
@@ -76,7 +76,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
[Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
{
ArgumentNullException.ThrowIfNull(userAuthority);
var dtoQueryable = await userAuthority.InvokeTransformableQueryable<Models.User, User, UserGraphQLTransformer>(
var dtoQueryable = await userAuthority.InvokeTransformableQueryable<Models.User, User, UserTransformer>(
authority => authority
.Queryable(false),
queryable => queryable.Where(user => user.GroupId == groupId));
@@ -8,7 +8,7 @@ using HotChocolate.Types.Relay;
using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.GraphQL.Interfaces;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.GraphQL.Types
{
@@ -31,7 +31,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformableAllowMissing<Models.User, UserName, UserNameGraphQLTransformer>(
return userAuthority.InvokeTransformableAllowMissing<Models.User, UserName, UserNameTransformer>(
authority => authority.GetId(id, false, true, cancellationToken));
}
@@ -14,7 +14,7 @@ using Microsoft.Extensions.Options;
using Tgstation.Server.Host.Authority;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.GraphQL.Types
{
@@ -46,7 +46,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userAuthority);
return userAuthority.InvokeTransformable<Models.User, User, UserGraphQLTransformer>(authority => authority.Read(cancellationToken));
return userAuthority.InvokeTransformable<Models.User, User, UserTransformer>(authority => authority.Read(cancellationToken));
}
/// <summary>
@@ -77,7 +77,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
[Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
{
ArgumentNullException.ThrowIfNull(userAuthority);
var dtoQueryable = await userAuthority.InvokeTransformableQueryable<Models.User, User, UserGraphQLTransformer>(
var dtoQueryable = await userAuthority.InvokeTransformableQueryable<Models.User, User, UserTransformer>(
authority => authority.Queryable(false));
return dtoQueryable;
}
@@ -1,13 +1,13 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.Models
{
/// <inheritdoc cref="Api.Models.OAuthConnection" />
public sealed class OAuthConnection : Api.Models.OAuthConnection,
ILegacyApiTransformable<Api.Models.OAuthConnection>,
IApiTransformable<OAuthConnection, GraphQL.Types.OAuth.OAuthConnection, OAuthConnectionGraphQLTransformer>
IApiTransformable<OAuthConnection, GraphQL.Types.OAuth.OAuthConnection, OAuthConnectionTransformer>
{
/// <summary>
/// The row Id.
@@ -1,13 +1,13 @@
using System.ComponentModel.DataAnnotations;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.Models
{
/// <inheritdoc cref="Api.Models.OidcConnection" />
public sealed class OidcConnection : Api.Models.OidcConnection,
ILegacyApiTransformable<Api.Models.OidcConnection>,
IApiTransformable<OidcConnection, GraphQL.Types.OAuth.OidcConnection, OidcConnectionGraphQLTransformer>
IApiTransformable<OidcConnection, GraphQL.Types.OAuth.OidcConnection, OidcConnectionTransformer>
{
/// <summary>
/// The row Id.
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.Models
{
/// <inheritdoc />
public sealed class PermissionSet : Api.Models.PermissionSet, IApiTransformable<PermissionSet, GraphQL.Types.PermissionSet, PermissionSetGraphQLTransformer>
public sealed class PermissionSet : Api.Models.PermissionSet, IApiTransformable<PermissionSet, GraphQL.Types.PermissionSet, PermissionSetTransformer>
{
/// <summary>
/// The <see cref="Api.Models.EntityId.Id"/> of <see cref="User"/>.
@@ -4,7 +4,7 @@ using System.Linq.Expressions;
using Tgstation.Server.Host.Authority.Core;
using Tgstation.Server.Host.Extensions;
namespace Tgstation.Server.Host.Models.Transformers
namespace Tgstation.Server.Host.Models
{
/// <inheritdoc />
abstract class TransformerBase<TInput, TOutput> : ITransformer<TInput, TOutput>
@@ -1,20 +0,0 @@
namespace Tgstation.Server.Host.Models.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="GraphQL.Types.OAuth.OAuthConnection"/>s.
/// </summary>
sealed class OAuthConnectionGraphQLTransformer : TransformerBase<OAuthConnection, GraphQL.Types.OAuth.OAuthConnection>
{
/// <summary>
/// Initializes a new instance of the <see cref="OAuthConnectionGraphQLTransformer"/> class.
/// </summary>
public OAuthConnectionGraphQLTransformer()
: base(model => new GraphQL.Types.OAuth.OAuthConnection
{
ExternalUserId = model.ExternalUserId ?? NotNullFallback<string>(),
Provider = model.Provider,
})
{
}
}
}
@@ -1,20 +0,0 @@
namespace Tgstation.Server.Host.Models.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="GraphQL.Types.OAuth.OidcConnection"/>s.
/// </summary>
sealed class OidcConnectionGraphQLTransformer : TransformerBase<OidcConnection, GraphQL.Types.OAuth.OidcConnection>
{
/// <summary>
/// Initializes a new instance of the <see cref="OidcConnectionGraphQLTransformer"/> class.
/// </summary>
public OidcConnectionGraphQLTransformer()
: base(model => new GraphQL.Types.OAuth.OidcConnection
{
ExternalUserId = model.ExternalUserId ?? NotNullFallback<string>(),
SchemeKey = model.SchemeKey ?? NotNullFallback<string>(),
})
{
}
}
}
@@ -1,18 +0,0 @@
namespace Tgstation.Server.Host.Models.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="UpdatedUser"/>s.
/// </summary>
sealed class UpdatedUserGraphQLTransformer : TransformerBase<UpdatedUser, GraphQL.Types.UpdatedUser>
{
/// <summary>
/// Initializes a new instance of the <see cref="UpdatedUserGraphQLTransformer"/> class.
/// </summary>
public UpdatedUserGraphQLTransformer()
: base(model => model.User != null
? new GraphQL.Types.UpdatedUser(model.User)
: new GraphQL.Types.UpdatedUser(model.Id))
{
}
}
}
@@ -1,24 +0,0 @@
namespace Tgstation.Server.Host.Models.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="GraphQL.Types.UserGroup"/>s.
/// </summary>
sealed class UserGroupGraphQLTransformer : TransformerBase<UserGroup, GraphQL.Types.UserGroup>
{
/// <summary>
/// Initializes a new instance of the <see cref="UserGroupGraphQLTransformer"/> class.
/// </summary>
public UserGroupGraphQLTransformer()
: base(
BuildSubProjection<PermissionSet, GraphQL.Types.PermissionSet, PermissionSetGraphQLTransformer>(
(model, permissionSet) => new GraphQL.Types.UserGroup
{
Id = model.Id!.Value,
Name = model.Name!,
PermissionSet = permissionSet!,
},
model => model.PermissionSet))
{
}
}
}
@@ -1,20 +0,0 @@
namespace Tgstation.Server.Host.Models.Transformers
{
/// <summary>
/// <see cref="ITransformer{TInput, TOutput}"/> for <see cref="GraphQL.Types.UserName"/>s.
/// </summary>
sealed class UserNameGraphQLTransformer : TransformerBase<User, GraphQL.Types.UserName>
{
/// <summary>
/// Initializes a new instance of the <see cref="UserNameGraphQLTransformer"/> class.
/// </summary>
public UserNameGraphQLTransformer()
: base(model => new GraphQL.Types.UserName
{
Id = model.Id!.Value,
Name = model.Name!,
})
{
}
}
}
@@ -1,7 +1,7 @@
using System;
using Tgstation.Server.Api.Models.Response;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.Models
{
@@ -10,7 +10,7 @@ namespace Tgstation.Server.Host.Models
/// </summary>
public sealed class UpdatedUser :
ILegacyApiTransformable<UserResponse>,
IApiTransformable<UpdatedUser, GraphQL.Types.UpdatedUser, UpdatedUserGraphQLTransformer>
IApiTransformable<UpdatedUser, GraphQL.Types.UpdatedUser, UpdatedUserTransformer>
{
/// <summary>
/// The <see cref="User"/>'s <see cref="Api.Models.EntityId.Id"/>.
+3 -3
View File
@@ -5,15 +5,15 @@ using System.Linq;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Response;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.Models
{
/// <inheritdoc cref="Api.Models.Internal.UserModelBase" />
public sealed class User : Api.Models.Internal.UserModelBase,
ILegacyApiTransformable<UserResponse>,
IApiTransformable<User, GraphQL.Types.User, UserGraphQLTransformer>,
IApiTransformable<User, GraphQL.Types.UserName, UserNameGraphQLTransformer>
IApiTransformable<User, GraphQL.Types.User, UserTransformer>,
IApiTransformable<User, GraphQL.Types.UserName, UserNameTransformer>
{
/// <summary>
/// Username used when creating jobs automatically.
@@ -5,14 +5,14 @@ using System.Linq;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Response;
using Tgstation.Server.Host.Models.Transformers;
using Tgstation.Server.Host.GraphQL.Transformers;
namespace Tgstation.Server.Host.Models
{
/// <summary>
/// Represents a group of <see cref="User"/>s.
/// </summary>
public sealed class UserGroup : NamedEntity, ILegacyApiTransformable<UserGroupResponse>, IApiTransformable<UserGroup, GraphQL.Types.UserGroup, UserGroupGraphQLTransformer>
public sealed class UserGroup : NamedEntity, ILegacyApiTransformable<UserGroupResponse>, IApiTransformable<UserGroup, GraphQL.Types.UserGroup, UserGroupTransformer>
{
/// <summary>
/// The <see cref="Models.PermissionSet"/> the <see cref="UserGroup"/> has.