diff --git a/src/Tgstation.Server.Host/GraphQL/Scalars/JwtType.cs b/src/Tgstation.Server.Host/GraphQL/Scalars/JwtType.cs index 170a744a42..fd6057392a 100644 --- a/src/Tgstation.Server.Host/GraphQL/Scalars/JwtType.cs +++ b/src/Tgstation.Server.Host/GraphQL/Scalars/JwtType.cs @@ -1,14 +1,11 @@ using System; -using HotChocolate.Language; -using HotChocolate.Types; - namespace Tgstation.Server.Host.GraphQL.Scalars { /// - /// A for encoded JSON Web Tokens. + /// A for encoded JSON Web Tokens. /// - public sealed class JwtType : ScalarType + public sealed class JwtType : StringScalarType { /// /// Initializes a new instance of the class. @@ -19,20 +16,5 @@ namespace Tgstation.Server.Host.GraphQL.Scalars Description = "Represents an encoded JSON Web Token"; SpecifiedBy = new Uri("https://datatracker.ietf.org/doc/html/rfc7519"); } - - /// - public override IValueNode ParseResult(object? resultValue) - => ParseValue(resultValue); - - /// - protected override string ParseLiteral(StringValueNode valueSyntax) - { - ArgumentNullException.ThrowIfNull(valueSyntax); - return valueSyntax.Value; - } - - /// - protected override StringValueNode ParseValue(string runtimeValue) - => new(runtimeValue); } } diff --git a/src/Tgstation.Server.Host/GraphQL/Scalars/StringScalarType.cs b/src/Tgstation.Server.Host/GraphQL/Scalars/StringScalarType.cs new file mode 100644 index 0000000000..05f4328946 --- /dev/null +++ b/src/Tgstation.Server.Host/GraphQL/Scalars/StringScalarType.cs @@ -0,0 +1,37 @@ +using System; + +using HotChocolate.Language; +using HotChocolate.Types; + +namespace Tgstation.Server.Host.GraphQL.Scalars +{ + /// + /// A for specialized types. + /// + public abstract class StringScalarType : ScalarType + { + /// + /// Initializes a new instance of the class. + /// + /// The name of the GraphQL scalar type. + public StringScalarType(string name) + : base(name) + { + } + + /// + public override IValueNode ParseResult(object? resultValue) + => ParseValue(resultValue); + + /// + protected override string ParseLiteral(StringValueNode valueSyntax) + { + ArgumentNullException.ThrowIfNull(valueSyntax); + return valueSyntax.Value; + } + + /// + protected override StringValueNode ParseValue(string runtimeValue) + => new(runtimeValue); + } +}