diff --git a/src/Tgstation.Server.Host/Authority/Core/AuthorityInvoker{TAuthority}.cs b/src/Tgstation.Server.Host/Authority/Core/AuthorityInvoker{TAuthority}.cs
index db3f06c803..3b6eb396b9 100644
--- a/src/Tgstation.Server.Host/Authority/Core/AuthorityInvoker{TAuthority}.cs
+++ b/src/Tgstation.Server.Host/Authority/Core/AuthorityInvoker{TAuthority}.cs
@@ -85,6 +85,23 @@ namespace Tgstation.Server.Host.Authority.Core
return CreateSuccessfulActionResult(controller, result, authorityResponse);
}
+ ///
+ public async ValueTask InvokeTransformable(Func>> authorityInvoker)
+ where TResult : notnull, IApiTransformable
+ where TApiModel : notnull
+ where TTransformer : ITransformer, new()
+ {
+ ArgumentNullException.ThrowIfNull(authorityInvoker);
+
+ var authorityResponse = await authorityInvoker(authority);
+ ThrowGraphQLErrorIfNecessary(authorityResponse);
+ var result = authorityResponse.Result;
+ if (result == null)
+ return default;
+
+ return result.ToApi();
+ }
+
///
async ValueTask IGraphQLAuthorityInvoker.Invoke(Func> authorityInvoker)
{
@@ -95,7 +112,7 @@ namespace Tgstation.Server.Host.Authority.Core
}
///
- public async ValueTask Invoke(Func>> authorityInvoker)
+ public async ValueTask Invoke(Func>> authorityInvoker)
where TResult : TApiModel
where TApiModel : notnull
{
@@ -103,17 +120,7 @@ namespace Tgstation.Server.Host.Authority.Core
var authorityResponse = await authorityInvoker(authority);
ThrowGraphQLErrorIfNecessary(authorityResponse);
- return authorityResponse.Result!;
- }
-
- ///
- async ValueTask IGraphQLAuthorityInvoker.InvokeTransformable(Func>> authorityInvoker)
- {
- ArgumentNullException.ThrowIfNull(authorityInvoker);
-
- var authorityResponse = await authorityInvoker(authority);
- ThrowGraphQLErrorIfNecessary(authorityResponse);
- return authorityResponse.Result!.ToApi();
+ return authorityResponse.Result;
}
///
diff --git a/src/Tgstation.Server.Host/Authority/Core/IGraphQLAuthorityInvoker{TAuthority}.cs b/src/Tgstation.Server.Host/Authority/Core/IGraphQLAuthorityInvoker{TAuthority}.cs
index 1c5031edc3..24102d8a01 100644
--- a/src/Tgstation.Server.Host/Authority/Core/IGraphQLAuthorityInvoker{TAuthority}.cs
+++ b/src/Tgstation.Server.Host/Authority/Core/IGraphQLAuthorityInvoker{TAuthority}.cs
@@ -26,7 +26,7 @@ namespace Tgstation.Server.Host.Authority.Core
/// The resulting of the return value.
/// The returning a resulting in the .
/// A resulting in the generated for the resulting .
- ValueTask Invoke(Func>> authorityInvoker)
+ ValueTask Invoke(Func>> authorityInvoker)
where TResult : TApiModel
where TApiModel : notnull;
@@ -38,7 +38,7 @@ namespace Tgstation.Server.Host.Authority.Core
/// The for converting s to s.
/// The returning a resulting in the .
/// A resulting in the generated for the resulting .
- ValueTask InvokeTransformable(Func>> authorityInvoker)
+ ValueTask InvokeTransformable(Func>> authorityInvoker)
where TResult : notnull, IApiTransformable
where TApiModel : notnull
where TTransformer : ITransformer, new();
diff --git a/src/Tgstation.Server.Host/GraphQL/Types/NodeInformation.cs b/src/Tgstation.Server.Host/GraphQL/Types/NodeInformation.cs
index 546d77d9f2..42af3c8176 100644
--- a/src/Tgstation.Server.Host/GraphQL/Types/NodeInformation.cs
+++ b/src/Tgstation.Server.Host/GraphQL/Types/NodeInformation.cs
@@ -14,6 +14,12 @@ namespace Tgstation.Server.Host.GraphQL.Types
[Node]
public sealed class NodeInformation
{
+ ///
+ /// Node resolver for s.
+ ///
+ /// The to lookup.
+ /// The to use.
+ /// The queried , if present.
public NodeInformation? GetNodeInformation(
string identifier,
[Service] ISwarmService swarmService)
diff --git a/src/Tgstation.Server.Host/GraphQL/Types/User.cs b/src/Tgstation.Server.Host/GraphQL/Types/User.cs
index efacb5525e..794f68c60a 100644
--- a/src/Tgstation.Server.Host/GraphQL/Types/User.cs
+++ b/src/Tgstation.Server.Host/GraphQL/Types/User.cs
@@ -51,13 +51,20 @@ namespace Tgstation.Server.Host.GraphQL.Types
[GraphQLIgnore]
public required long? GroupId { get; init; }
- public static ValueTask GetUser(
+ ///
+ /// Node resolver for s.
+ ///
+ /// The to lookup.
+ /// The .
+ /// The for the operation.
+ /// A resulting in the queried , if present.
+ public static ValueTask GetUser(
long id,
- [Service] IGraphQLAuthorityInvoker authorityInvoker,
+ [Service] IGraphQLAuthorityInvoker userAuthority,
CancellationToken cancellationToken)
{
- ArgumentNullException.ThrowIfNull(authorityInvoker);
- return authorityInvoker.InvokeTransformable(
+ ArgumentNullException.ThrowIfNull(userAuthority);
+ return userAuthority.InvokeTransformable(
authority => authority.GetId(id, false, false, cancellationToken));
}
@@ -76,6 +83,9 @@ namespace Tgstation.Server.Host.GraphQL.Types
return null;
var user = await userAuthority.InvokeTransformable(authority => authority.GetId(CreatedById.Value, false, true, cancellationToken));
+ if (user == null)
+ return null;
+
if (user.CanonicalName == Models.User.CanonicalizeName(Models.User.TgsSystemUserName))
return new UserName(user);
diff --git a/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs b/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs
index 3379741f91..555fbc4ad8 100644
--- a/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs
+++ b/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs
@@ -19,15 +19,25 @@ namespace Tgstation.Server.Host.GraphQL.Types
[Node]
public sealed class UserName : NamedEntity, IUserName
{
- public static async ValueTask GetUserName(
+ ///
+ /// Node resolver for s.
+ ///
+ /// The to lookup.
+ /// The .
+ /// The for the operation.
+ /// A resulting in the queried , if present.
+ public static async ValueTask GetUserName(
long id,
- [Service] IGraphQLAuthorityInvoker authorityInvoker,
+ [Service] IGraphQLAuthorityInvoker userAuthority,
CancellationToken cancellationToken)
{
- ArgumentNullException.ThrowIfNull(authorityInvoker);
- var user = await authorityInvoker.InvokeTransformable(
+ ArgumentNullException.ThrowIfNull(userAuthority);
+ var user = await userAuthority.InvokeTransformable(
authority => authority.GetId(id, false, true, cancellationToken));
+ if (user == null)
+ return null;
+
return new UserName(user);
}
diff --git a/src/Tgstation.Server.Host/GraphQL/Types/Users.cs b/src/Tgstation.Server.Host/GraphQL/Types/Users.cs
index fcba0f00ea..f4d718e43f 100644
--- a/src/Tgstation.Server.Host/GraphQL/Types/Users.cs
+++ b/src/Tgstation.Server.Host/GraphQL/Types/Users.cs
@@ -34,7 +34,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(userAuthority);
- return userAuthority.InvokeTransformable(authority => authority.Read(cancellationToken));
+ return userAuthority.InvokeTransformable(authority => authority.Read(cancellationToken))!;
}
///
diff --git a/src/Tgstation.Server.Host/Models/IApiTransformable{TModel,TApiModel,TTransformer}.cs b/src/Tgstation.Server.Host/Models/IApiTransformable{TModel,TApiModel,TTransformer}.cs
index df45b7d7e8..0fff10e229 100644
--- a/src/Tgstation.Server.Host/Models/IApiTransformable{TModel,TApiModel,TTransformer}.cs
+++ b/src/Tgstation.Server.Host/Models/IApiTransformable{TModel,TApiModel,TTransformer}.cs
@@ -11,6 +11,7 @@ namespace Tgstation.Server.Host.Models
/// The API model .
/// The .
public interface IApiTransformable
+ where TApiModel : notnull
where TModel : IApiTransformable
where TTransformer : ITransformer, new()
{
diff --git a/src/Tgstation.Server.Host/Models/Transformers/TransformerBase{TModel,TApiModel}.cs b/src/Tgstation.Server.Host/Models/Transformers/TransformerBase{TInput,TOutput}.cs
similarity index 100%
rename from src/Tgstation.Server.Host/Models/Transformers/TransformerBase{TModel,TApiModel}.cs
rename to src/Tgstation.Server.Host/Models/Transformers/TransformerBase{TInput,TOutput}.cs