tgstation-server 6.19.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
Mutation.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4
5using HotChocolate;
6using HotChocolate.Authorization;
7using HotChocolate.Types;
8
11
13{
18 [Authorize]
19 [GraphQLDescription(GraphQLDescription)]
20 public sealed class Mutation
21 {
25 public const string GraphQLDescription = "Root Mutation type";
26
33 [AllowAnonymous]
34 [Error(typeof(ErrorMessageException))]
35 public ValueTask<LoginResult> Login(
36 [Service] IGraphQLAuthorityInvoker<ILoginAuthority> loginAuthority,
37 CancellationToken cancellationToken)
38 {
39 ArgumentNullException.ThrowIfNull(loginAuthority);
40
41 return loginAuthority.Invoke<LoginResult, LoginResult>(
42 authority => authority.AttemptLogin(cancellationToken));
43 }
44
51 [AllowAnonymous]
52 [Error(typeof(ErrorMessageException))]
53 public ValueTask<OAuthGatewayLoginResult> OAuthGateway(
54 [Service] IGraphQLAuthorityInvoker<ILoginAuthority> loginAuthority,
55 CancellationToken cancellationToken)
56 {
57 ArgumentNullException.ThrowIfNull(loginAuthority);
58
59 return loginAuthority.Invoke<OAuthGatewayLoginResult, OAuthGatewayLoginResult>(
60 authority => authority.AttemptOAuthGatewayLogin(cancellationToken));
61 }
62 }
63}
Exception representing ErrorMessageResponses.
Root type for GraphQL mutations.
Definition Mutation.cs:21
const string GraphQLDescription
Description to show on the Mutation type.
Definition Mutation.cs:25
ValueTask< OAuthGatewayLoginResult > OAuthGateway([Service] IGraphQLAuthorityInvoker< ILoginAuthority > loginAuthority, CancellationToken cancellationToken)
Generate an OAuth user token for the requested service. This requires the OAuth authentication scheme...
Definition Mutation.cs:53
ValueTask< LoginResult > Login([Service] IGraphQLAuthorityInvoker< ILoginAuthority > loginAuthority, CancellationToken cancellationToken)
Generate a JWT for authenticating with server. This requires either the Basic authentication or OAuth...
Definition Mutation.cs:35