tgstation-server 6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
UserGroupsRepository.cs
Go to the documentation of this file.
1using System;
2using System.Linq;
3using System.Threading;
4using System.Threading.Tasks;
5
6using HotChocolate;
7using HotChocolate.Data;
8using HotChocolate.Types;
9using HotChocolate.Types.Relay;
10
13
15{
19 public sealed class UserGroupsRepository
20 {
27 public ValueTask<UserGroup?> Current(
28 [Service] IGraphQLAuthorityInvoker<IUserGroupAuthority> userGroupAuthority,
29 CancellationToken cancellationToken)
30 {
31 ArgumentNullException.ThrowIfNull(userGroupAuthority);
32 return userGroupAuthority.InvokeTransformableAllowMissing<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(authority => authority.Read(cancellationToken));
33 }
34
42 public ValueTask<UserGroup?> ById(
43 [ID(nameof(UserGroup))] long id,
44 [Service] IGraphQLAuthorityInvoker<IUserGroupAuthority> userGroupAuthority,
45 CancellationToken cancellationToken)
46 => UserGroup.GetUserGroup(id, userGroupAuthority, cancellationToken);
47
53 [UsePaging]
54 [UseFiltering]
55 [UseSorting]
56 public async ValueTask<IQueryable<UserGroup>> QueryableGroups(
57 [Service] IGraphQLAuthorityInvoker<IUserGroupAuthority> userGroupAuthority)
58 {
59 ArgumentNullException.ThrowIfNull(userGroupAuthority);
60 var dtoQueryable = await userGroupAuthority.InvokeTransformableQueryable<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(
61 authority => authority.Queryable(false));
62 return dtoQueryable;
63 }
64
71 [UsePaging]
72 [UseFiltering]
73 [UseSorting]
74 public async ValueTask<IQueryable<User>> QueryableUsersByGroupId(
75 [ID(nameof(UserGroup))] long groupId,
76 [Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
77 {
78 ArgumentNullException.ThrowIfNull(userAuthority);
79 var dtoQueryable = await userAuthority.InvokeTransformableQueryable<Models.User, User, UserGraphQLTransformer>(
80 authority => authority
81 .Queryable(false),
82 queryable => queryable.Where(user => user.GroupId == groupId));
83 return dtoQueryable;
84 }
85 }
86}
static ValueTask< UserGroup?> GetUserGroup(long id, [Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority, CancellationToken cancellationToken)
Node resolver for Users.
Definition UserGroup.cs:29
ValueTask< UserGroup?> ById([ID(nameof(UserGroup))] long id, [Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority, CancellationToken cancellationToken)
Gets a UserGroup by Entity.Id.
async ValueTask< IQueryable< User > > QueryableUsersByGroupId([ID(nameof(UserGroup))] long groupId, [Service] IGraphQLAuthorityInvoker< IUserAuthority > userAuthority)
Queries all registered Users in a UserGroup indicated by groupId .
ValueTask< UserGroup?> Current([Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority, CancellationToken cancellationToken)
Gets the current User.
async ValueTask< IQueryable< UserGroup > > QueryableGroups([Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority)
Queries all registered UserGroups.
A user registered in the server.
Definition User.cs:27
ITransformer<TInput, TOutput> for GraphQL.Types.Users.
ITransformer<TInput, TOutput> for GraphQL.Types.UserGroups.