From 5b135fbc25db35ebef311e58722f755f5effbdd5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 15 Sep 2024 14:23:08 -0400 Subject: [PATCH] Makes sense to have recursive lookups here. Cost analyzer should be protecting us --- .../GraphQL/Types/UserGroup.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs b/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs index b555f203e0..c9c5fcede2 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs @@ -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( authority => authority.GetId(Id, PermissionSetLookupType.GroupId, cancellationToken)))!; } + + /// + /// Queries all registered s in the . + /// + /// The . + /// A of all registered s in the indicated by . + [UsePaging] + [UseFiltering] + [UseSorting] + [TgsGraphQLAuthorize(nameof(IUserAuthority.Queryable))] + public IQueryable QueryableUsersByGroup( + [Service] IGraphQLAuthorityInvoker userAuthority) + { + ArgumentNullException.ThrowIfNull(userAuthority); + var dtoQueryable = userAuthority.InvokeTransformableQueryable( + authority => authority + .Queryable(false) + .Where(user => user.GroupId == Id)); + return dtoQueryable; + } } }