Skip to content

Commit bffdc6b

Browse files
Merge branch 'release' into dependabot/nuget/GraphQL_Version-4.4.0
2 parents f596cf2 + 88bac86 commit bffdc6b

12 files changed

Lines changed: 133 additions & 68 deletions

File tree

.assets/img/diagram.png

18.5 KB
Loading

.vscode/launch.json

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,37 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"name": ".NET Core Launch (webAPI)",
5+
"name": "WebAPI",
66
"type": "coreclr",
77
"request": "launch",
88
"preLaunchTask": "build",
9-
"program": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/bin/Debug/net5.0/Dotnet5.GraphQL3.Store.WebAPI.dll",
9+
"program": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/bin/Debug/net6.0/Dotnet6.GraphQL4.Store.WebAPI.dll",
1010
"args": [],
11-
"cwd": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI",
11+
"cwd": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI",
1212
"stopAtEntry": false,
1313
"serverReadyAction": {
1414
"action": "openExternally",
15-
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
15+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
16+
"uriFormat": "%s/ui/playground"
1617
},
1718
"env": {
1819
"ASPNETCORE_ENVIRONMENT": "Development"
1920
},
2021
"sourceFileMap": {
2122
"/Views": "${workspaceFolder}/Views"
23+
},
24+
"launchBrowser": {
25+
"enabled": true
2226
}
2327
},
2428
{
25-
"name": ".NET Core Launch (webMVC)",
29+
"name": "WebMVC",
2630
"type": "coreclr",
2731
"request": "launch",
2832
"preLaunchTask": "build",
29-
"program": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebMVC/bin/Debug/net5.0/Dotnet5.GraphQL3.Store.WebMVC.dll",
33+
"program": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/bin/Debug/net6.0/Dotnet6.GraphQL4.Store.WebMVC.dll",
3034
"args": [],
31-
"cwd": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebMVC",
35+
"cwd": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC",
3236
"stopAtEntry": false,
3337
"serverReadyAction": {
3438
"action": "openExternally",
@@ -39,13 +43,18 @@
3943
},
4044
"sourceFileMap": {
4145
"/Views": "${workspaceFolder}/Views"
46+
},
47+
"launchBrowser": {
48+
"enabled": true
4249
}
43-
},
50+
}
51+
],
52+
"compounds": [
4453
{
45-
"name": ".NET Core Attach",
46-
"type": "coreclr",
47-
"request": "attach",
48-
"processId": "${command:pickProcess}"
54+
"name": "WebAPI/WebMVC",
55+
"configurations": ["WebAPI", "WebMVC"],
56+
"preLaunchTask": "${defaultBuildTask}",
57+
"stopAll": true
4958
}
5059
]
5160
}

.vscode/tasks.json

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "process",
88
"args": [
99
"build",
10-
"${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/Dotnet5.GraphQL3.Store.WebAPI.csproj",
10+
"${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/Dotnet6.GraphQL4.Store.WebAPI.csproj",
1111
"/property:GenerateFullPaths=true",
1212
"/consoleloggerparameters:NoSummary"
1313
],
@@ -19,7 +19,7 @@
1919
"type": "process",
2020
"args": [
2121
"publish",
22-
"${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/Dotnet5.GraphQL3.Store.WebAPI.csproj",
22+
"${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/Dotnet6.GraphQL4.Store.WebAPI.csproj",
2323
"/property:GenerateFullPaths=true",
2424
"/consoleloggerparameters:NoSummary"
2525
],
@@ -32,7 +32,44 @@
3232
"args": [
3333
"watch",
3434
"run",
35-
"${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/Dotnet5.GraphQL3.Store.WebAPI.csproj",
35+
"${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/Dotnet6.GraphQL4.Store.WebAPI.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
},
41+
{
42+
"label": "build",
43+
"command": "dotnet",
44+
"type": "process",
45+
"args": [
46+
"build",
47+
"${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/Dotnet6.GraphQL4.Store.WebMVC.csproj",
48+
"/property:GenerateFullPaths=true",
49+
"/consoleloggerparameters:NoSummary"
50+
],
51+
"problemMatcher": "$msCompile"
52+
},
53+
{
54+
"label": "publish",
55+
"command": "dotnet",
56+
"type": "process",
57+
"args": [
58+
"publish",
59+
"${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/Dotnet6.GraphQL4.Store.WebMVC.csproj",
60+
"/property:GenerateFullPaths=true",
61+
"/consoleloggerparameters:NoSummary"
62+
],
63+
"problemMatcher": "$msCompile"
64+
},
65+
{
66+
"label": "watch",
67+
"command": "dotnet",
68+
"type": "process",
69+
"args": [
70+
"watch",
71+
"run",
72+
"${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/Dotnet6.GraphQL4.Store.WebMVC.csproj",
3673
"/property:GenerateFullPaths=true",
3774
"/consoleloggerparameters:NoSummary"
3875
],

README.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ This project exemplifies the implementation and **dockerization** of a simple Ra
2020

2121
---
2222

23+
![diagram](./.assets/img/diagram.png)
24+
25+
---
26+
2327
## Running
2428

2529
### Development (secrets)
@@ -171,27 +175,29 @@ networks:
171175
```
172176
### GraphQL Playground
173177
174-
By default **Playground** respond at `http://localhost:5000/ui/playground` but is possible configure the host and many others details in [`../....WebAPI/Graphs/Extensions/DependencyInjection/ApplicationBuilderExtensions.cs`](./src/Dotnet6.GraphQL4.Store.WebAPI/Graphs/Extensions/DependencyInjection/ApplicationBuilderExtensions.cs)
178+
By default **Playground** respond at `http://localhost:5000/ui/playground` but is possible configure the host and many others details in [`../DependencyInjection/Extensions/ApplicationBuilderExtensions.cs`](./src/Dotnet6.GraphQL4.Store.WebAPI/DependencyInjection/Extensions/ApplicationBuilderExtensions.cs)
175179

176180
```c#
177181
app.UseGraphQLPlayground(
178-
new GraphQLPlaygroundOptions
179-
{
180-
Path = "/ui/playground",
181-
BetaUpdates = true,
182-
RequestCredentials = RequestCredentials.Omit,
183-
HideTracingResponse = false,
184-
EditorCursorShape = EditorCursorShape.Line,
185-
EditorTheme = EditorTheme.Dark,
186-
EditorFontSize = 14,
187-
EditorReuseHeaders = true,
188-
EditorFontFamily = "JetBrains Mono"
189-
});
182+
options: new()
183+
{
184+
BetaUpdates = true,
185+
RequestCredentials = RequestCredentials.Omit,
186+
HideTracingResponse = false,
187+
EditorCursorShape = EditorCursorShape.Line,
188+
EditorTheme = EditorTheme.Dark,
189+
EditorFontSize = 14,
190+
EditorReuseHeaders = true,
191+
EditorFontFamily = "JetBrains Mono"
192+
},
193+
path: "/ui/playground");
190194
```
191195

192196
### Health checks
193197

194-
Based on cloud-native concepts, **Readiness** and **Liveness** integrity verification strategies were implemented.
198+
Based on cloud-native concepts, **Readiness** and **Liveness** integrity verification strategies were implemented.
199+
200+
If using [xabarilcoding/healthchecksui](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/doc/ui-docker.md) container image it will responde on `http://localhost:8000/healthchecks-ui/`.
195201

196202
> `/health`
197203
> Just check if the instance is running.
@@ -248,8 +254,8 @@ The implementation of the `UnitOfWork` gives support to the `ExecutionStrategy`
248254
```c#
249255
public Task<Review> AddReviewAsync(ReviewModel reviewModel, CancellationToken cancellationToken)
250256
{
251-
return UnitOfWork.ExecuteInTransactionAsync(
252-
operationAsync: async ct => // Func<CancellationToken, Task<TResult>>
257+
return UnitOfWork.ExecuteInTransactionScopeAsync(
258+
operationAsync: async ct =>
253259
{
254260
var product = await Repository.GetByIdAsync(
255261
id: reviewModel.ProductId,
@@ -262,8 +268,8 @@ public Task<Review> AddReviewAsync(ReviewModel reviewModel, CancellationToken ca
262268
await OnEditAsync(product, ct);
263269
return review;
264270
},
265-
condition: _ => NotificationContext.AllValidAsync, // Func<CancellationToken, Task<bool>>
266-
cancellationToken: cancellationToken);
271+
condition: _ => NotificationContext.AllValidAsync,
272+
cancellationToken: cancellationToken);
267273
}
268274
```
269275

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
4+
namespace Dotnet6.GraphQL4.Domain.Abstractions.ValueObjects
5+
{
6+
public abstract class ValueObject
7+
{
8+
protected static bool EqualOperator(ValueObject left, ValueObject right)
9+
=> (ReferenceEquals(left, null) ^ ReferenceEquals(right, null)) is false &&
10+
(ReferenceEquals(left, null) || left.Equals(right));
11+
12+
protected static bool NotEqualOperator(ValueObject left, ValueObject right)
13+
=> EqualOperator(left, right) is false;
14+
15+
protected abstract IEnumerable<object> GetEqualityComponents();
16+
17+
public override bool Equals(object obj)
18+
=> obj is not null && obj.GetType() == GetType() &&
19+
GetEqualityComponents().SequenceEqual(((ValueObject) obj).GetEqualityComponents());
20+
21+
public override int GetHashCode()
22+
=> GetEqualityComponents()
23+
.Select(x => x != null ? x.GetHashCode() : 0)
24+
.Aggregate((x, y) => x ^ y);
25+
}
26+
}
Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
using System;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using Dotnet6.GraphQL4.Store.WebAPI.Graphs;
54
using Dotnet6.GraphQL4.Store.WebAPI.Graphs.Executers;
65
using GraphQL;
76
using GraphQL.Server;
7+
using Microsoft.AspNetCore.Hosting;
88
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Hosting;
910
using Serilog;
1011

1112
namespace Dotnet6.GraphQL4.Store.WebAPI.DependencyInjection.Extensions
1213
{
1314
public static class ServiceCollectionExtensions
1415
{
15-
private static readonly Options Options = new();
16-
17-
public static IGraphQLBuilder AddApplicationGraphQL(this IServiceCollection services, Action<Options> actionOptions)
18-
{
19-
actionOptions(Options);
20-
21-
return services
16+
public static IGraphQLBuilder AddApplicationGraphQL(this IServiceCollection services)
17+
=> services
2218
.AddScoped(typeof(IGraphQLExecuter<>), typeof(StoreGraphQLExecuter<>))
2319
.AddScoped<IDocumentExecuter, StoreDocumentExecuter>()
2420
.AddSingleton<StoreSchema>()
2521
.AddGraphQL(
26-
(options, _) =>
22+
(options, serviceProvider) =>
2723
{
28-
options.EnableMetrics = Options.IsDevelopment;
24+
options.EnableMetrics = serviceProvider.GetRequiredService<IWebHostEnvironment>().IsDevelopment();
2925

3026
options.UnhandledExceptionDelegate = exceptionContext
3127
=> Log.Error(
@@ -44,11 +40,5 @@ public static IGraphQLBuilder AddApplicationGraphQL(this IServiceCollection serv
4440
.AddWebSockets()
4541
.AddDataLoader()
4642
.AddGraphTypes(typeof(StoreSchema));
47-
}
48-
}
49-
50-
public class Options
51-
{
52-
public bool IsDevelopment { get; set; }
5343
}
5444
}

src/Dotnet6.GraphQL4.Store.WebAPI/Graphs/StoreQuery.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public StoreQuery()
4343
.Name("Reviews")
4444
.Argument<GuidGraphType>("productId")
4545
.Resolve()
46-
.WithScope()
4746
.WithService<IProductService>()
4847
.ResolveAsync(
4948
async (context, service) =>

src/Dotnet6.GraphQL4.Store.WebAPI/Properties/launchSettings.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
"windowsAuthentication": false,
44
"anonymousAuthentication": true,
55
"iisExpress": {
6-
"applicationUrl": "http://localhost:46086/",
7-
"sslPort": 44365
6+
"applicationUrl": "http://localhost:5000/"
87
}
98
},
109
"profiles": {
1110
"IIS Express": {
1211
"commandName": "IISExpress",
13-
"launchBrowser": false,
12+
"launchBrowser": true,
13+
"launchUrl": "ui/playground",
1414
"environmentVariables": {
1515
"ASPNETCORE_ENVIRONMENT": "Development"
1616
}
1717
},
1818
"Dotnet5.GraphQL.Store.WebAPI": {
1919
"commandName": "Project",
20-
"launchBrowser": false,
21-
"applicationUrl": "http://localhost:5000/",
20+
"launchBrowser": true,
21+
"applicationUrl": "http://localhost:5000",
22+
"launchUrl": "ui/playground",
2223
"environmentVariables": {
2324
"ASPNETCORE_ENVIRONMENT": "Development"
2425
}

src/Dotnet6.GraphQL4.Store.WebAPI/Startup.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public void Configure(IApplicationBuilder app , ILoggerFactory loggerFactory)
8282

8383
public void ConfigureServices(IServiceCollection services)
8484
{
85+
services.ConfigureTransactionOptions(_configuration.GetSection("Transactions"));
86+
services.ConfigureSqlServerRetryingOptions(_configuration.GetSection("SqlServerRetryingOptions"));
87+
8588
services
8689
.AddLogging()
8790
.AddBuilders()
@@ -92,15 +95,10 @@ public void ConfigureServices(IServiceCollection services)
9295
.AddApplicationMessageServices()
9396
.AddApplicationSubjects()
9497
.AddApplicationAutoMapper()
98+
.AddApplicationDbContext()
9599
.AddControllers();
96100

97-
services.ConfigureTransactionOptions(_configuration.GetSection("Transactions"));
98-
services.ConfigureSqlServerRetryingOptions(_configuration.GetSection("SqlServerRetryingOptions"));
99-
100-
services.AddApplicationDbContext();
101-
102-
services.AddApplicationGraphQL(options
103-
=> options.IsDevelopment = _env.IsDevelopment());
101+
services.AddApplicationGraphQL();
104102

105103
services.Configure<KestrelServerOptions>(options
106104
=> options.AllowSynchronousIO = true);

src/Dotnet6.GraphQL4.Store.WebAPI/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"MinimumLevel": {
1818
"Default": "Debug",
1919
"Override": {
20-
"Microsoft": "Warning",
20+
"Microsoft": "Information",
2121
"Microsoft.Hosting.Lifetime": "Information"
2222
}
2323
}

0 commit comments

Comments
 (0)