diff --git a/Sheaft.Application.Queries/BusinessQueries.cs b/Sheaft.Application.Queries/BusinessQueries.cs index c2f83decb..c05972119 100644 --- a/Sheaft.Application.Queries/BusinessQueries.cs +++ b/Sheaft.Application.Queries/BusinessQueries.cs @@ -270,6 +270,13 @@ public IQueryable GetProducer(Guid id, RequestUser currentUser) .ProjectTo(_configurationProvider); } + public IQueryable GetProducers(RequestUser currentUser) + { + return _context.Users.OfType() + .Get() + .ProjectTo(_configurationProvider); + } + public IQueryable GetStore(Guid id, RequestUser currentUser) { return _context.Users.OfType() diff --git a/Sheaft.Application.Queries/Interop/IBusinessQueries.cs b/Sheaft.Application.Queries/Interop/IBusinessQueries.cs index 74f3246b2..9e816162d 100644 --- a/Sheaft.Application.Queries/Interop/IBusinessQueries.cs +++ b/Sheaft.Application.Queries/Interop/IBusinessQueries.cs @@ -17,5 +17,6 @@ public interface IBusinessQueries Task SearchProducersAsync(Guid storeId, SearchTermsInput terms, RequestUser currentUser, CancellationToken token); Task SearchStoresAsync(Guid producerId, SearchTermsInput terms, RequestUser currentUser, CancellationToken token); Task> SuggestProducersAsync(SearchTermsInput terms, RequestUser currentUser, CancellationToken token); + IQueryable GetProducers(RequestUser currentUser); } } \ No newline at end of file diff --git a/Sheaft.GraphQL.Filters/ProducerSummaryFilterType.cs b/Sheaft.GraphQL.Filters/ProducerSummaryFilterType.cs new file mode 100644 index 000000000..9b3d79012 --- /dev/null +++ b/Sheaft.GraphQL.Filters/ProducerSummaryFilterType.cs @@ -0,0 +1,15 @@ +using HotChocolate.Types.Filters; +using Sheaft.Application.Models; + +namespace Sheaft.GraphQL.Filters +{ + public class ProducerSummaryFilterType : FilterInputType + { + protected override void Configure(IFilterInputTypeDescriptor descriptor) + { + descriptor.BindFieldsExplicitly(); + descriptor.Filter(c => c.Id).AllowEquals(); + descriptor.Filter(c => c.Name).AllowContains(); + } + } +} diff --git a/Sheaft.GraphQL.Filters/ProductFilterType.cs b/Sheaft.GraphQL.Filters/ProductFilterType.cs index 15ad3d5fe..23297c120 100644 --- a/Sheaft.GraphQL.Filters/ProductFilterType.cs +++ b/Sheaft.GraphQL.Filters/ProductFilterType.cs @@ -13,5 +13,5 @@ protected override void Configure(IFilterInputTypeDescriptor descrip descriptor.Filter(c => c.Name).AllowContains(); descriptor.Filter(c => c.Reference).AllowContains(); } - } + } } diff --git a/Sheaft.GraphQL.Services/SheaftQuery.cs b/Sheaft.GraphQL.Services/SheaftQuery.cs index b7c44780d..a6550c730 100644 --- a/Sheaft.GraphQL.Services/SheaftQuery.cs +++ b/Sheaft.GraphQL.Services/SheaftQuery.cs @@ -146,6 +146,13 @@ public IQueryable GetProducer(Guid input, [Service] IBusinessQueries busin return businessQueries.GetProducer(input, CurrentUser); } + public IQueryable GetProducers([Service] IBusinessQueries businessQueries) + { + SetLogTransaction("GraphQL", nameof(GetProducers)); + return businessQueries.GetProducers(CurrentUser); + } + + public IQueryable GetConsumer(Guid input, [Service] IConsumerQueries consumerQueries) { SetLogTransaction("GraphQL", nameof(GetConsumer), input); diff --git a/Sheaft.GraphQL.Sorts/ProducerSummarySortType.cs b/Sheaft.GraphQL.Sorts/ProducerSummarySortType.cs new file mode 100644 index 000000000..63f0d3af6 --- /dev/null +++ b/Sheaft.GraphQL.Sorts/ProducerSummarySortType.cs @@ -0,0 +1,14 @@ +using HotChocolate.Types.Sorting; +using Sheaft.Application.Models; + +namespace Sheaft.GraphQL.Sorts +{ + public class ProducerSummarySortType : SortInputType + { + protected override void Configure(ISortInputTypeDescriptor descriptor) + { + descriptor.BindFieldsExplicitly(); + descriptor.Sortable(c => c.Name); + } + } +} diff --git a/Sheaft.GraphQL.Sorts/ProductQuantitySortType.cs b/Sheaft.GraphQL.Sorts/ProductQuantitySortType.cs index cea1fa13d..48b6276c2 100644 --- a/Sheaft.GraphQL.Sorts/ProductQuantitySortType.cs +++ b/Sheaft.GraphQL.Sorts/ProductQuantitySortType.cs @@ -10,5 +10,5 @@ protected override void Configure(ISortInputTypeDescriptor c.Name); } - } + } } diff --git a/Sheaft.GraphQL.Types/SheaftQueryType.cs b/Sheaft.GraphQL.Types/SheaftQueryType.cs index e82cb10e9..e62f4e9da 100644 --- a/Sheaft.GraphQL.Types/SheaftQueryType.cs +++ b/Sheaft.GraphQL.Types/SheaftQueryType.cs @@ -242,6 +242,14 @@ protected override void Configure(IObjectTypeDescriptor descriptor) .UseSingleOrDefault() .UseSelection(); + descriptor.Field(c => c.GetProducers(default)) + .Name("producers") + .Type>>() + .UsePaging() + .UseFiltering() + .UseSorting() + .UseSelection(); + descriptor.Field(c => c.GetProducerProducts(default, default)) .Name("producerProducts") .Authorize(Policies.STORE)