tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
UserGroups.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
14
16{
20 public sealed class UserGroups
21 {
27 public ValueTask<UserGroup?> Current(
28 [Service] IGraphQLAuthorityInvoker<IUserGroupAuthority> userGroupAuthority)
29 {
30 ArgumentNullException.ThrowIfNull(userGroupAuthority);
31 return userGroupAuthority.InvokeTransformableAllowMissing<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(authority => authority.Read());
32 }
33
41 [TgsGraphQLAuthorize<IUserAuthority>(nameof(IUserGroupAuthority.GetId))]
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 [TgsGraphQLAuthorize<IUserGroupAuthority>(nameof(IUserGroupAuthority.Queryable))]
58 [Service] IGraphQLAuthorityInvoker<IUserGroupAuthority> userGroupAuthority)
59 {
60 ArgumentNullException.ThrowIfNull(userGroupAuthority);
61 var dtoQueryable = userGroupAuthority.InvokeTransformableQueryable<Models.UserGroup, UserGroup, UserGroupGraphQLTransformer>(authority => authority.Queryable(false));
62 return dtoQueryable;
63 }
64
71 [UsePaging]
72 [UseFiltering]
73 [UseSorting]
74 [TgsGraphQLAuthorize<IUserGroupAuthority>(nameof(IUserAuthority.Queryable))]
76 [ID(nameof(UserGroup))]long groupId,
77 [Service] IGraphQLAuthorityInvoker<IUserAuthority> userAuthority)
78 {
79 ArgumentNullException.ThrowIfNull(userAuthority);
80 var dtoQueryable = userAuthority.InvokeTransformableQueryable<Models.User, User, UserGraphQLTransformer>(
81 authority => authority
82 .Queryable(false)
83 .Where(user => user.GroupId == groupId));
84 return dtoQueryable;
85 }
86 }
87}
static ValueTask< UserGroup?> GetUserGroup(long id, [Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority, CancellationToken cancellationToken)
Node resolver for Users.
Definition UserGroup.cs:31
Wrapper for accessing UserGroups.
Definition UserGroups.cs:21
ValueTask< UserGroup?> Current([Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority)
Gets the current User.
Definition UserGroups.cs:27
IQueryable< UserGroup > QueryableGroups([Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority)
Queries all registered UserGroups.
Definition UserGroups.cs:57
ValueTask< UserGroup?> ById([ID(nameof(UserGroup))] long id, [Service] IGraphQLAuthorityInvoker< IUserGroupAuthority > userGroupAuthority, CancellationToken cancellationToken)
Gets a UserGroup by Entity.Id.
IQueryable< User > QueryableUsersByGroupId([ID(nameof(UserGroup))]long groupId, [Service] IGraphQLAuthorityInvoker< IUserAuthority > userAuthority)
Queries all registered Users in a UserGroup indicated by groupId .
Definition UserGroups.cs:75
A user registered in the server.
Definition User.cs:21
ITransformer<TInput, TOutput> for GraphQL.Types.Users.
ITransformer<TInput, TOutput> for GraphQL.Types.UserGroups.
IQueryable< User > Queryable(bool includeJoins)
Gets all registered Users.
ValueTask< AuthorityResponse< UserGroup > > GetId(long id, bool includeJoins, CancellationToken cancellationToken)
Gets the UserGroup with a given id .
IQueryable< UserGroup > Queryable(bool includeJoins)
Gets all registered UserGroups.