Skip to content

Commit 76f68f3

Browse files
Merge pull request #150 from AntonioFalcao/release
Updating
2 parents 8884f7d + 0c8abc9 commit 76f68f3

File tree

41 files changed

+553
-435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+553
-435
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
<!--GraphQL-->
1616
<GraphQL_Server_Version>4.4.1</GraphQL_Server_Version>
17-
<GraphQL_Client_Version>3.2.1</GraphQL_Client_Version>
17+
<GraphQL_Client_Version>3.2.2</GraphQL_Client_Version>
1818
<GraphQL_Version>3.3.2</GraphQL_Version>
1919

2020
<!--AutoMapper-->
2121
<AutoMapper_DependencyInjection_Version>8.1.1</AutoMapper_DependencyInjection_Version>
2222
<AutoMapper_Version>10.1.1</AutoMapper_Version>
2323

2424
<!--Others-->
25-
<FluentValidation_Version>9.5.0</FluentValidation_Version>
25+
<FluentValidation_Version>9.5.1</FluentValidation_Version>
2626
<Scrutor_Version>3.3.0</Scrutor_Version>
2727

2828
</PropertyGroup>

README.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -347,29 +347,27 @@ networks:
347347

348348
Based on cloud-native concepts, **Readiness** and **Liveness** integrity verification strategies were implemented.
349349

350-
Web API
351-
352-
`http://localhost:5000/health/ready`
350+
> `/health`
351+
> Just check if the instance is running.
353352

354-
![Readiness](./.assets/img/Readiness.png)
353+
> `/health/live`
354+
> Check if the instance is running and all the dependencies too.
355355

356+
> `/health/ready`
357+
> Check if the instance and all the dependencies are ready to attend to all functionalities.
356358

357-
`http://localhost:5000/health/live`
359+
Web API
358360

359-
![Liveness](./.assets/img/Liveness.png)
361+
`http://localhost:5000/health/ready`
360362
361-
---
363+
![Readiness](./.assets/img/Readiness.png)
362364

363365
Web MVC
364366

365367
`http://localhost:7000/health/ready`
366368
367369
![Readiness](./.assets/img/ReadinessMVC.png)
368370

369-
`http://localhost:7000/health/live`
370-
371-
![Liveness](./.assets/img/LivenessMVC.png)
372-
373371
---
374372

375373
### GraphQL Playground
@@ -685,14 +683,8 @@ We use [SemVer](http://semver.org/) for versioning. For the versions available,
685683

686684
## Authors
687685

688-
* **Antônio Falcão** - [GitHub](https://github.com/AntonioFalcao)
689-
690-
> See also the list of [contributors](https://github.com/AntonioFalcao/Dotnet5.GraphQL.WebApplication/graphs/contributors) who participated in this project.
686+
> See the list of [contributors](https://github.com/AntonioFalcao/Dotnet5.GraphQL.WebApplication/graphs/contributors) who participated in this project.
691687
692688
## License
693689

694690
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details
695-
696-
## Acknowledgments
697-
698-
* Nothing more, for now.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
6+
namespace Dotnet5.GraphQL3.CrossCutting
7+
{
8+
public static class Application
9+
{
10+
public static string Prefix { get; } = Assembly.GetEntryAssembly()?.FullName?.Substring(0, 16);
11+
public static IEnumerable<Assembly> Assemblies { get; } =
12+
AppDomain.CurrentDomain.GetAssemblies().Where(assembly => assembly.FullName?.StartsWith(Prefix) ?? false);
13+
}
14+
}

src/Dotnet5.GraphQL3.CrossCutting/Extensions/LocalAssemblyExtensions.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Dotnet5.GraphQL3.Domain.Abstractions/Extensions/DependencyInjection/ServiceCollectionExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Dotnet5.GraphQL3.CrossCutting.Extensions;
1+
using Dotnet5.GraphQL3.CrossCutting;
22
using Dotnet5.GraphQL3.Domain.Abstractions.Builders;
33
using Microsoft.Extensions.DependencyInjection;
44
using Scrutor;
@@ -8,12 +8,9 @@ namespace Dotnet5.GraphQL3.Domain.Abstractions.Extensions.DependencyInjection
88
public static class ServiceCollectionExtensions
99
{
1010
public static IServiceCollection AddBuilders(this IServiceCollection services)
11-
=> services.Scan(selector
12-
=> selector
13-
.FromApplicationDependencies(assembly
14-
=> assembly.FullName?.StartsWith(assembly.GetEntryAssemblySuffix()) ?? default)
15-
.AddClasses(filter
16-
=> filter.AssignableTo(typeof(IBuilder<,>)))
11+
=> services
12+
.Scan(selector => selector.FromAssemblies(Application.Assemblies)
13+
.AddClasses(filter => filter.AssignableTo(typeof(IBuilder<,>)))
1714
.UsingRegistrationStrategy(RegistrationStrategy.Skip)
1815
.AsImplementedInterfaces()
1916
.WithScopedLifetime());

src/Dotnet5.GraphQL3.Repositories.Abstractions/Dotnet5.GraphQL3.Repositories.Abstractions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<ItemGroup>
4+
<PackageReference Include="AutoMapper" Version="$(AutoMapper_Version)" />
45
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(Microsoft_EntityFrameworkCore_Version)" />
56
<PackageReference Include="Scrutor" Version="$(Scrutor_Version)" />
67
</ItemGroup>

src/Dotnet5.GraphQL3.Repositories.Abstractions/Extensions/DependencyInjection/ServiceCollectionExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Dotnet5.GraphQL3.CrossCutting.Extensions;
1+
using Dotnet5.GraphQL3.CrossCutting;
22
using Dotnet5.GraphQL3.Repositories.Abstractions.UnitsOfWork;
33
using Microsoft.Extensions.DependencyInjection;
44
using Scrutor;
@@ -8,12 +8,9 @@ namespace Dotnet5.GraphQL3.Repositories.Abstractions.Extensions.DependencyInject
88
public static class ServiceCollectionExtensions
99
{
1010
public static IServiceCollection AddRepositories(this IServiceCollection services)
11-
=> services.Scan(selector
12-
=> selector
13-
.FromApplicationDependencies(assembly
14-
=> assembly.FullName?.StartsWith(assembly.GetEntryAssemblySuffix()) ?? default)
15-
.AddClasses(filter
16-
=> filter.AssignableTo(typeof(IRepository<,>)))
11+
=> services
12+
.Scan(selector => selector.FromAssemblies(Application.Assemblies)
13+
.AddClasses(filter => filter.AssignableTo(typeof(IRepository<,>)))
1714
.UsingRegistrationStrategy(RegistrationStrategy.Skip)
1815
.AsImplementedInterfaces()
1916
.WithScopedLifetime());

src/Dotnet5.GraphQL3.Repositories.Abstractions/IRepository.cs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,50 @@ public interface IRepository<TEntity, in TId>
1414
where TId : struct
1515
{
1616
TEntity Add(TEntity entity);
17-
Task<TEntity> AddAsync(TEntity entity, CancellationToken cancellationToken = default);
17+
Task<TEntity> AddAsync(TEntity entity, CancellationToken cancellationToken);
1818

1919
void Delete(TId id);
2020
void Delete(TEntity entity);
21-
Task DeleteAsync(TId id, CancellationToken cancellationToken = default);
21+
Task DeleteAsync(TId id, CancellationToken cancellationToken);
22+
Task DeleteAsync(TEntity entity, CancellationToken cancellationToken);
2223

2324
bool Exists(TId id);
24-
Task<bool> ExistsAsync(TId id, CancellationToken cancellationToken = default);
25+
Task<bool> ExistsAsync(TId id, CancellationToken cancellationToken);
2526

26-
TEntity GetById(TId id, Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default,
27-
bool asTracking = default);
28-
29-
Task<TEntity> GetByIdAsync(TId id, CancellationToken cancellationToken,
30-
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default,
31-
bool asTracking = default);
27+
TEntity GetById(TId id, Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default, bool asTracking = default);
28+
Task<TEntity> GetByIdAsync(TId id, CancellationToken cancellationToken, Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default, bool asTracking = default);
3229

3330
void Update(TEntity entity);
34-
Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default);
31+
Task UpdateAsync(TEntity entity, CancellationToken cancellationToken);
3532

36-
PagedResult<TResult> GetAll<TResult>(
33+
PagedResult<TEntity> GetAll(
3734
PageParams pageParams,
38-
Expression<Func<TEntity, TResult>> selector,
39-
Expression<Func<TEntity, bool>> predicate,
35+
Expression<Func<TEntity, bool>> predicate = default,
36+
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = default,
37+
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default,
38+
bool asTracking = default);
39+
40+
PagedResult<TResult> GetAllProjections<TResult>(
41+
PageParams pageParams,
42+
Expression<Func<TEntity, TResult>> selector = default,
43+
Expression<Func<TEntity, bool>> predicate = default,
4044
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = default,
4145
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default,
4246
bool asTracking = default);
4347

44-
Task<PagedResult<TResult>> GetAllAsync<TResult>(
48+
Task<PagedResult<TEntity>> GetAllAsync(
49+
PageParams pageParams,
50+
CancellationToken cancellationToken,
51+
Expression<Func<TEntity, bool>> predicate = default,
52+
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = default,
53+
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default,
54+
bool asTracking = default);
55+
56+
Task<PagedResult<TResult>> GetAllProjectionsAsync<TResult>(
4557
PageParams pageParams,
46-
Expression<Func<TEntity, TResult>> selector,
47-
Expression<Func<TEntity, bool>> predicate,
4858
CancellationToken cancellationToken,
59+
Expression<Func<TEntity, TResult>> selector = default,
60+
Expression<Func<TEntity, bool>> predicate = default,
4961
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = default,
5062
Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = default,
5163
bool asTracking = default);

src/Dotnet5.GraphQL3.Repositories.Abstractions/Pages/PagedResult.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,41 @@ namespace Dotnet5.GraphQL3.Repositories.Abstractions.Pages
88
{
99
public class PagedResult<T>
1010
{
11+
private readonly IReadOnlyCollection<T> _items;
1112
private readonly int _index;
12-
private readonly IEnumerable<T> _items;
1313
private readonly int _size;
1414

15-
public PagedResult(IEnumerable<T> items, int index, int size)
15+
public PagedResult(IReadOnlyCollection<T> items, int index, int size)
1616
{
1717
_items = items;
1818
_index = index;
1919
_size = size;
2020
}
2121

22-
public IEnumerable<T> Items => _items.Take(_size);
22+
public IReadOnlyCollection<T> Items
23+
=> _items.Take(_size).ToList();
2324

2425
public PageInfo PageInfo
2526
=> new()
2627
{
2728
Current = _index,
28-
Size = Items.Count(),
29-
HasNext = _size < _items.Count(),
29+
Size = Items.Count,
30+
HasNext = _size < _items.Count,
3031
HasPrevious = _index > 1
3132
};
3233

3334
public static async Task<PagedResult<T>> CreateAsync(IQueryable<T> source, PageParams pageParams, CancellationToken cancellationToken)
3435
{
35-
pageParams ??= new PageParams();
36+
pageParams ??= new();
3637
var items = await ApplyPagination(source, pageParams).ToListAsync(cancellationToken);
37-
return new PagedResult<T>(items, pageParams.Index, pageParams.Size);
38+
return new(items, pageParams.Index, pageParams.Size);
3839
}
3940

4041
public static PagedResult<T> Create(IQueryable<T> source, PageParams pageParams)
4142
{
42-
pageParams ??= new PageParams();
43-
var items = ApplyPagination(source, pageParams);
44-
return new PagedResult<T>(items, pageParams.Index, pageParams.Size);
43+
pageParams ??= new();
44+
var items = ApplyPagination(source, pageParams).ToList();
45+
return new(items, pageParams.Index, pageParams.Size);
4546
}
4647

4748
private static IQueryable<T> ApplyPagination(IQueryable<T> source, PageParams pageParams)

0 commit comments

Comments
 (0)