Skip to content

Commit

Permalink
refactor: use Object, Query, Mutation and Subscription type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILLIPS71 committed May 30, 2024
1 parent c0c883d commit 3b0a12b
Show file tree
Hide file tree
Showing 50 changed files with 189 additions and 397 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Giantnodes.Infrastructure.GraphQL.Scalars;

public class CharFilterConvention : FilterConvention
public sealed class CharFilterConvention : FilterConvention
{
protected override void Configure(IFilterConventionDescriptor descriptor)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Giantnodes.Infrastructure.GraphQL.Scalars;

public class CharOperationFilterInputType : ComparableOperationFilterInputType<CharType>
public sealed class CharOperationFilterInputType : ComparableOperationFilterInputType<CharType>
{
protected override void Configure(IFilterInputTypeDescriptor descriptor)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/src/GraphQL/Scalars/CharType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Giantnodes.Infrastructure.GraphQL.Scalars;

public class CharType : ScalarType<char, StringValueNode>
public sealed class CharType : ScalarType<char, StringValueNode>
{
/// <summary>
/// Initializes a new instance of the <see cref="CharType"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Directories.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class DirectoryProbeMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Directories.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class FileSystemDirectoryFindOne
{
[GraphQLType<ListType<FileSystemEntryType>>]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
using Giantnodes.Infrastructure;
using Giantnodes.Infrastructure.Faults.Exceptions;
using Giantnodes.Infrastructure.Faults.Types;
using Giantnodes.Infrastructure.Validation.Exceptions;
using Giantnodes.Service.Dashboard.Application.Contracts.Directories.Queries;
using Giantnodes.Service.Dashboard.Domain.Enumerations;
using Giantnodes.Service.Dashboard.HttpApi.Resolvers.Directories.Types;
using MassTransit;

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Directories.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
public class GetFileResolutionDistributionQuery
{
[Error<DomainException>]
[Error<ValidationException>]
[UseSorting]
public async Task<IQueryable<FileResolutionDistribution>> FileResolutionDistribution(
[Service] IRequestClient<GetFileResolutionDistribution.Query> request,
[ID] Guid directoryId,
CancellationToken cancellation = default)
{
var query = new GetFileResolutionDistribution.Query
{
DirectoryId = directoryId
};

Response response = await request.GetResponse<GetFileResolutionDistribution.Result, DomainFault, ValidationFault>(query, cancellation);
return response switch
{
(_, GetFileResolutionDistribution.Result result) => result.Distribution
.Select(x => new FileResolutionDistribution
{
Resolution = Enumeration.TryParse<VideoResolution>(x.Key ?? 0),
Count = x.Value
})
.AsQueryable(),
(_, DomainFault fault) => throw new DomainException(fault),
(_, ValidationFault fault) => throw new ValidationException(fault),
_ => throw new InvalidOperationException()
};
}
}
// using Giantnodes.Infrastructure;
// using Giantnodes.Infrastructure.Faults.Exceptions;
// using Giantnodes.Infrastructure.Faults.Types;
// using Giantnodes.Infrastructure.Validation.Exceptions;
// using Giantnodes.Service.Dashboard.Application.Contracts.Directories.Queries;
// using Giantnodes.Service.Dashboard.Domain.Enumerations;
// using MassTransit;
//
// namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Directories.Queries;
//
// public readonly record struct FileResolutionDistribution(VideoResolution? Resolution, int Count);
//
// [QueryType]
// public class GetFileResolutionDistributionQuery
// {
// [Error<DomainException>]
// [Error<ValidationException>]
// [UseSorting]
// public async Task<IQueryable<FileResolutionDistribution>> FileResolutionDistribution(
// [Service] IRequestClient<GetFileResolutionDistribution.Query> request,
// [ID] Guid directoryId,
// CancellationToken cancellation = default)
// {
// var query = new GetFileResolutionDistribution.Query
// {
// DirectoryId = directoryId
// };
//
// Response response = await request.GetResponse<GetFileResolutionDistribution.Result, DomainFault, ValidationFault>(query, cancellation);
// return response switch
// {
// (_, GetFileResolutionDistribution.Result result) =>
// result
// .Distribution
// .Select(x => new FileResolutionDistribution
// {
// Resolution = Enumeration.TryParse<VideoResolution>(x.Key ?? 0),
// Count = x.Value
// })
// .AsQueryable(),
// (_, DomainFault fault) => throw new DomainException(fault),
// (_, ValidationFault fault) => throw new ValidationException(fault),
// _ => throw new InvalidOperationException()
// };
// }
// }
//
// // [ObjectType<FileResolutionDistribution>]
// // public static partial class FileResolutionDistributionType
// // {
// // static partial void Configure(IObjectTypeDescriptor<FileResolutionDistribution> descriptor)
// // {
// // descriptor
// // .Field(p => p.Resolution);
// //
// // descriptor
// // .Field(p => p.Count);
// // }
// // }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Giantnodes.Infrastructure.Faults;
using Giantnodes.Infrastructure.Faults.Exceptions;
using Giantnodes.Infrastructure.Faults.Types;
using Giantnodes.Infrastructure.Validation.Exceptions;
Expand All @@ -8,7 +9,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class EncodeCancelMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class EncodeSubmitMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class EncodeFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class EncodeFindOne
{
[UseFirstOrDefault]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class EncodeQueueFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Subscriptions;

[ExtendObjectType(OperationTypeNames.Subscription)]
[SubscriptionType]
public class EncodeOutputtedSubscription
{
[Subscribe]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Subscriptions;

[ExtendObjectType(OperationTypeNames.Subscription)]
[SubscriptionType]
public class EncodeProgressedSubscription
{
[Subscribe]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Subscriptions;

[ExtendObjectType(OperationTypeNames.Subscription)]
[SubscriptionType]
public class EncodeSpeedChangeSubscription
{
[Subscribe]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Subscriptions;

[ExtendObjectType(OperationTypeNames.Subscription)]
[SubscriptionType]
public class EncodeStatusChangedSubscription
{
[Subscribe]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Enumerations.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class EncodeCodecFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Enumerations.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class EncodePresetFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Enumerations.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class EncodeTuneFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Enumerations.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class VideoFileContainerFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Libraries.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class LibraryCreateMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Libraries.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class LibraryUpdateMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Libraries.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class LibraryFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Libraries.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class LibraryFindOne
{
[UseFirstOrDefault]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Recipes.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class RecipeCreateMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Recipes.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class RecipeDeleteMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Recipes.Mutations;

[ExtendObjectType(OperationTypeNames.Mutation)]
[MutationType]
public class RecipeUpdateMutation
{
[Error<DomainException>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Recipes.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class RecipeFindMany
{
[UsePaging]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Recipes.Queries;

[ExtendObjectType(OperationTypeNames.Query)]
[QueryType]
public class RecipeFindOne
{
[UseFirstOrDefault]
Expand Down
Loading

0 comments on commit 3b0a12b

Please sign in to comment.