mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-21 12:06:59 +01:00
Makes sense to have recursive lookups here. Cost analyzer should be protecting us
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using HotChocolate;
|
||||
using HotChocolate.Data;
|
||||
using HotChocolate.Types;
|
||||
using HotChocolate.Types.Relay;
|
||||
using Tgstation.Server.Host.Authority;
|
||||
|
||||
@@ -50,5 +53,25 @@ namespace Tgstation.Server.Host.GraphQL.Types
|
||||
return (await permissionSetAuthority.InvokeTransformable<Models.PermissionSet, PermissionSet, PermissionSetGraphQLTransformer>(
|
||||
authority => authority.GetId(Id, PermissionSetLookupType.GroupId, cancellationToken)))!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queries all registered <see cref="User"/>s in the <see cref="UserGroup"/>.
|
||||
/// </summary>
|
||||
/// <param name="userAuthority">The <see cref="IGraphQLAuthorityInvoker{TAuthority}"/> <see cref="IUserAuthority"/>.</param>
|
||||
/// <returns>A <see cref="IQueryable{T}"/> of all registered <see cref="User"/>s in the <see cref="UserGroup"/> indicated by <paramref name="groupId"/>.</returns>
|
||||
[UsePaging]
|
||||
[UseFiltering]
|
||||
[UseSorting]
|
||||
[TgsGraphQLAuthorize<IUserGroupAuthority>(nameof(IUserAuthority.Queryable))]
|
||||
public IQueryable<User> QueryableUsersByGroup(
|
||||
[Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(userAuthority);
|
||||
var dtoQueryable = userAuthority.InvokeTransformableQueryable<Models.User, User, UserGraphQLTransformer>(
|
||||
authority => authority
|
||||
.Queryable(false)
|
||||
.Where(user => user.GroupId == Id));
|
||||
return dtoQueryable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user