diff --git a/.assets/img/diagram.png b/.assets/img/diagram.png new file mode 100644 index 00000000..a6b76538 Binary files /dev/null and b/.assets/img/diagram.png differ diff --git a/.vscode/launch.json b/.vscode/launch.json index 66d000de..1543be43 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,33 +2,37 @@ "version": "0.2.0", "configurations": [ { - "name": ".NET Core Launch (webAPI)", + "name": "WebAPI", "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/bin/Debug/net5.0/Dotnet5.GraphQL3.Store.WebAPI.dll", + "program": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/bin/Debug/net6.0/Dotnet6.GraphQL4.Store.WebAPI.dll", "args": [], - "cwd": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI", + "cwd": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI", "stopAtEntry": false, "serverReadyAction": { "action": "openExternally", - "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + "pattern": "\\bNow listening on:\\s+(https?://\\S+)", + "uriFormat": "%s/ui/playground" }, "env": { "ASPNETCORE_ENVIRONMENT": "Development" }, "sourceFileMap": { "/Views": "${workspaceFolder}/Views" + }, + "launchBrowser": { + "enabled": true } }, { - "name": ".NET Core Launch (webMVC)", + "name": "WebMVC", "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebMVC/bin/Debug/net5.0/Dotnet5.GraphQL3.Store.WebMVC.dll", + "program": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/bin/Debug/net6.0/Dotnet6.GraphQL4.Store.WebMVC.dll", "args": [], - "cwd": "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebMVC", + "cwd": "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC", "stopAtEntry": false, "serverReadyAction": { "action": "openExternally", @@ -39,13 +43,18 @@ }, "sourceFileMap": { "/Views": "${workspaceFolder}/Views" + }, + "launchBrowser": { + "enabled": true } - }, + } + ], + "compounds": [ { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" + "name": "WebAPI/WebMVC", + "configurations": ["WebAPI", "WebMVC"], + "preLaunchTask": "${defaultBuildTask}", + "stopAll": true } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5fe850b7..740bef45 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,7 @@ "type": "process", "args": [ "build", - "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/Dotnet5.GraphQL3.Store.WebAPI.csproj", + "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/Dotnet6.GraphQL4.Store.WebAPI.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], @@ -19,7 +19,7 @@ "type": "process", "args": [ "publish", - "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/Dotnet5.GraphQL3.Store.WebAPI.csproj", + "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/Dotnet6.GraphQL4.Store.WebAPI.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], @@ -32,7 +32,44 @@ "args": [ "watch", "run", - "${workspaceFolder}/src/Dotnet5.GraphQL3.Store.WebAPI/Dotnet5.GraphQL3.Store.WebAPI.csproj", + "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebAPI/Dotnet6.GraphQL4.Store.WebAPI.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/Dotnet6.GraphQL4.Store.WebMVC.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/Dotnet6.GraphQL4.Store.WebMVC.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/Dotnet6.GraphQL4.Store.WebMVC/Dotnet6.GraphQL4.Store.WebMVC.csproj", "/property:GenerateFullPaths=true", "/consoleloggerparameters:NoSummary" ], diff --git a/Directory.Build.props b/Directory.Build.props index 5f5e08ef..dd352e0c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -16,9 +16,9 @@ 6.0.0-preview.3.21201.13 - 5.0.1 + 5.0.2 3.2.3 - 4.3.0 + 4.5.0 8.1.1 @@ -31,7 +31,7 @@ 5.0.1 - 10.0.4 + 10.1.0 3.3.0 diff --git a/README.md b/README.md index 530a7eb4..1cda4221 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ This project exemplifies the implementation and **dockerization** of a simple Ra --- +![diagram](./.assets/img/diagram.png) + +--- + ## Running ### Development (secrets) @@ -171,27 +175,29 @@ networks: ``` ### GraphQL Playground -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) +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) ```c# app.UseGraphQLPlayground( - new GraphQLPlaygroundOptions - { - Path = "/ui/playground", - BetaUpdates = true, - RequestCredentials = RequestCredentials.Omit, - HideTracingResponse = false, - EditorCursorShape = EditorCursorShape.Line, - EditorTheme = EditorTheme.Dark, - EditorFontSize = 14, - EditorReuseHeaders = true, - EditorFontFamily = "JetBrains Mono" - }); + options: new() + { + BetaUpdates = true, + RequestCredentials = RequestCredentials.Omit, + HideTracingResponse = false, + EditorCursorShape = EditorCursorShape.Line, + EditorTheme = EditorTheme.Dark, + EditorFontSize = 14, + EditorReuseHeaders = true, + EditorFontFamily = "JetBrains Mono" + }, + path: "/ui/playground"); ``` ### Health checks -Based on cloud-native concepts, **Readiness** and **Liveness** integrity verification strategies were implemented. +Based on cloud-native concepts, **Readiness** and **Liveness** integrity verification strategies were implemented. + +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/`. > `/health` > Just check if the instance is running. @@ -248,8 +254,8 @@ The implementation of the `UnitOfWork` gives support to the `ExecutionStrategy` ```c# public Task AddReviewAsync(ReviewModel reviewModel, CancellationToken cancellationToken) { - return UnitOfWork.ExecuteInTransactionAsync( - operationAsync: async ct => // Func> + return UnitOfWork.ExecuteInTransactionScopeAsync( + operationAsync: async ct => { var product = await Repository.GetByIdAsync( id: reviewModel.ProductId, @@ -262,8 +268,8 @@ public Task AddReviewAsync(ReviewModel reviewModel, CancellationToken ca await OnEditAsync(product, ct); return review; }, - condition: _ => NotificationContext.AllValidAsync, // Func> - cancellationToken: cancellationToken); + condition: _ => NotificationContext.AllValidAsync, + cancellationToken: cancellationToken); } ``` diff --git a/src/Dotnet6.GraphQL4.Store.WebAPI/Graphs/StoreQuery.cs b/src/Dotnet6.GraphQL4.Store.WebAPI/Graphs/StoreQuery.cs index f4e4bddc..50eb4182 100644 --- a/src/Dotnet6.GraphQL4.Store.WebAPI/Graphs/StoreQuery.cs +++ b/src/Dotnet6.GraphQL4.Store.WebAPI/Graphs/StoreQuery.cs @@ -43,7 +43,6 @@ public StoreQuery() .Name("Reviews") .Argument("productId") .Resolve() - .WithScope() .WithService() .ResolveAsync( async (context, service) => diff --git a/src/Dotnet6.GraphQL4.Store.WebAPI/Properties/launchSettings.json b/src/Dotnet6.GraphQL4.Store.WebAPI/Properties/launchSettings.json index 952d2c1a..bea663ff 100644 --- a/src/Dotnet6.GraphQL4.Store.WebAPI/Properties/launchSettings.json +++ b/src/Dotnet6.GraphQL4.Store.WebAPI/Properties/launchSettings.json @@ -3,22 +3,23 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:46086/", - "sslPort": 44365 + "applicationUrl": "http://localhost:5000/" } }, "profiles": { "IIS Express": { "commandName": "IISExpress", - "launchBrowser": false, + "launchBrowser": true, + "launchUrl": "ui/playground", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, "Dotnet5.GraphQL.Store.WebAPI": { "commandName": "Project", - "launchBrowser": false, - "applicationUrl": "http://localhost:5000/", + "launchBrowser": true, + "applicationUrl": "http://localhost:5000", + "launchUrl": "ui/playground", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Dotnet6.GraphQL4.Store.WebMVC/Clients/StoreGraphClient.cs b/src/Dotnet6.GraphQL4.Store.WebMVC/Clients/StoreGraphClient.cs index e08839c8..448b97a7 100644 --- a/src/Dotnet6.GraphQL4.Store.WebMVC/Clients/StoreGraphClient.cs +++ b/src/Dotnet6.GraphQL4.Store.WebMVC/Clients/StoreGraphClient.cs @@ -89,7 +89,7 @@ public async Task> GetReviewByProductIdAsync(Guid id, C { var request = new GraphQLRequest { - Query = @"query ReviewsByProductQuery($productId: ID!) { + Query = @"query ReviewsByProductQuery($productId: Guid!) { reviews(productId: $productId) { id title diff --git a/src/Dotnet6.GraphQL4.Store.WebMVC/Properties/launchSettings.json b/src/Dotnet6.GraphQL4.Store.WebMVC/Properties/launchSettings.json index 4ba6ee11..02a64366 100644 --- a/src/Dotnet6.GraphQL4.Store.WebMVC/Properties/launchSettings.json +++ b/src/Dotnet6.GraphQL4.Store.WebMVC/Properties/launchSettings.json @@ -3,8 +3,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:48344/", - "sslPort": 44359 + "applicationUrl": "http://localhost:7000" } }, "profiles": { @@ -18,7 +17,7 @@ "Dotnet5.GraphQL.Store.WebMVC": { "commandName": "Project", "launchBrowser": true, - "applicationUrl": "http://localhost:7000/", + "applicationUrl": "http://localhost:7000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }