diff --git a/Sources/API Gateway/ocelot.json b/Sources/API Gateway/ocelot.json new file mode 100644 index 0000000..145b368 --- /dev/null +++ b/Sources/API Gateway/ocelot.json @@ -0,0 +1,28 @@ +{ + "Routes": [ + { + "DownstreamPathTemplate": "/api/joueur", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "localhost", + "Port": 5001 + } + ], + "UpstreamPathTemplate": "/rest/joueur", + "UpstreamHttpMethod": [ "Get", "Post" ] + }, + { + "DownstreamPathTemplate": "/graphql", + "DownstreamScheme": "http", + "DownstreamHostAndPorts": [ + { + "Host": "localhost", + "Port": 5002 + } + ], + "UpstreamPathTemplate": "/graphql", + "UpstreamHttpMethod": [ "get" ] + } + ] +} \ No newline at end of file diff --git a/Sources/BowlingApi/Properties/launchSettings.json b/Sources/BowlingApi/Properties/launchSettings.json index 018693f..fc48bb7 100644 --- a/Sources/BowlingApi/Properties/launchSettings.json +++ b/Sources/BowlingApi/Properties/launchSettings.json @@ -27,6 +27,15 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, + "RestFull": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:5001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, diff --git a/Sources/GraphQL Project/Data/JoueurAddedPayload.cs b/Sources/GraphQL Project/Data/JoueurAddedPayload.cs new file mode 100644 index 0000000..6cfb2dd --- /dev/null +++ b/Sources/GraphQL Project/Data/JoueurAddedPayload.cs @@ -0,0 +1,13 @@ +using DTOs; + +namespace GraphQL_Project.Data; + +public class JoueurAddedPayload +{ + public JoueurDTO Joueur { get; } + + public JoueurAddedPayload(JoueurDTO joueur) + { + Joueur = joueur ?? throw new ArgumentNullException(nameof(joueur)); + } +} \ No newline at end of file diff --git a/Sources/GraphQL Project/Data/Mutation.cs b/Sources/GraphQL Project/Data/Mutation.cs new file mode 100644 index 0000000..3932829 --- /dev/null +++ b/Sources/GraphQL Project/Data/Mutation.cs @@ -0,0 +1,18 @@ +using BowlingService.Interfaces; +using DTOs; +using GraphQL_Project.Record; + +namespace GraphQL_Project.Data; + +public class Mutation +{ + public async Task AddjoueurAsync(AddJoueurInput input, [Service] IJoueurService joueurService) + { + JoueurDTO joueurDto = new JoueurDTO + { + Pseudo = input.Pseudo + }; + var result = await joueurService.Add(joueurDto); + return new JoueurAddedPayload(result); + } +} \ No newline at end of file diff --git a/Sources/GraphQL Project/Program.cs b/Sources/GraphQL Project/Program.cs index 818e024..9f243fe 100644 --- a/Sources/GraphQL Project/Program.cs +++ b/Sources/GraphQL Project/Program.cs @@ -3,6 +3,7 @@ using BowlingRepository.Interface; using BowlingService; using BowlingService.Interfaces; using GraphQL_Project; +using GraphQL_Project.Data; using Mapper; var builder = WebApplication.CreateBuilder(args); @@ -10,11 +11,14 @@ var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddGraphQLServer() - .AddQueryType(); + .AddQueryType() + .AddMutationType(); builder.Services.AddAutoMapper(typeof(JoueurProfile)); builder.Services.AddScoped(); builder.Services.AddScoped(); + + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/Sources/GraphQL Project/Properties/launchSettings.json b/Sources/GraphQL Project/Properties/launchSettings.json index 491e83b..fedf6f9 100644 --- a/Sources/GraphQL Project/Properties/launchSettings.json +++ b/Sources/GraphQL Project/Properties/launchSettings.json @@ -16,6 +16,15 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, + "GraphQL": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:5002", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, diff --git a/Sources/GraphQL Project/Record/AddJoueurInput.cs b/Sources/GraphQL Project/Record/AddJoueurInput.cs new file mode 100644 index 0000000..ba483c2 --- /dev/null +++ b/Sources/GraphQL Project/Record/AddJoueurInput.cs @@ -0,0 +1,3 @@ +namespace GraphQL_Project.Record; + +public record AddJoueurInput(string Pseudo); \ No newline at end of file diff --git a/Sources/GraphQL Project/bowling.db b/Sources/GraphQL Project/bowling.db index ebb188c..67440ac 100644 Binary files a/Sources/GraphQL Project/bowling.db and b/Sources/GraphQL Project/bowling.db differ diff --git a/Sources/GraphQL Project/bowling.db-shm b/Sources/GraphQL Project/bowling.db-shm deleted file mode 100644 index fe9ac28..0000000 Binary files a/Sources/GraphQL Project/bowling.db-shm and /dev/null differ diff --git a/Sources/GraphQL Project/bowling.db-wal b/Sources/GraphQL Project/bowling.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/Sources/Solution.sln b/Sources/Solution.sln index b5bc35a..1072afa 100644 --- a/Sources/Solution.sln +++ b/Sources/Solution.sln @@ -37,6 +37,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BowlingAPITest", "Tests\Bow EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL Project", "GraphQL Project\GraphQL Project.csproj", "{F8016AE7-A927-4E68-A7CF-303AB3B8C2C3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API Gateway", "API Gateway\API Gateway.csproj", "{20E9E8DF-B3CA-4F4C-9B16-5E880158C43C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiBowlingGateway", "ApiBowlingGateway\ApiBowlingGateway.csproj", "{C3274794-8D2A-4695-B8B5-7B0B7B65C917}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -87,6 +91,14 @@ Global {F8016AE7-A927-4E68-A7CF-303AB3B8C2C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8016AE7-A927-4E68-A7CF-303AB3B8C2C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8016AE7-A927-4E68-A7CF-303AB3B8C2C3}.Release|Any CPU.Build.0 = Release|Any CPU + {20E9E8DF-B3CA-4F4C-9B16-5E880158C43C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20E9E8DF-B3CA-4F4C-9B16-5E880158C43C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20E9E8DF-B3CA-4F4C-9B16-5E880158C43C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20E9E8DF-B3CA-4F4C-9B16-5E880158C43C}.Release|Any CPU.Build.0 = Release|Any CPU + {C3274794-8D2A-4695-B8B5-7B0B7B65C917}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3274794-8D2A-4695-B8B5-7B0B7B65C917}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3274794-8D2A-4695-B8B5-7B0B7B65C917}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3274794-8D2A-4695-B8B5-7B0B7B65C917}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE