Skip to content

Commit 7624e78

Browse files
committed
#5 simplify the code
1 parent 6724f40 commit 7624e78

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

src/Cik.Magazine.ApiGateway/Controllers/GraphQLController.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,34 @@
88

99
namespace Cik.Magazine.ApiGateway.Controllers
1010
{
11+
/// <summary>
12+
/// The main controller for the graphql endpoint
13+
/// </summary>
1114
[Route("graphql")]
1215
public class GraphQLController : Controller
1316
{
1417
private readonly IDocumentExecuter _documentExecuter;
1518
private readonly ILogger _logger;
1619
private readonly ISchema _schema;
1720

21+
/// <summary>
22+
/// The constructor of the GraphQLController
23+
/// </summary>
24+
/// <param name="documentExecuter"></param>
25+
/// <param name="schema"></param>
26+
/// <param name="logger"></param>
1827
public GraphQLController(IDocumentExecuter documentExecuter, ISchema schema, ILogger<GraphQLController> logger)
1928
{
2029
_documentExecuter = documentExecuter;
2130
_schema = schema;
2231
_logger = logger;
2332
}
2433

34+
/// <summary>
35+
/// Post action is the main and only one action for submit the query and mutation of GraphQL
36+
/// </summary>
37+
/// <param name="query"></param>
38+
/// <returns></returns>
2539
[HttpPost]
2640
public async Task<IActionResult> Post([FromBody] GraphQLQuery query)
2741
{

src/Cik.Magazine.ApiGateway/GraphQL/Category/CategoryType.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ public class CategoryType : ObjectGraphType<CategoryGraph>
66
{
77
public CategoryType()
88
{
9+
Name = "Category";
10+
Description = "The category type in the magazine system";
11+
912
Field(x => x.Id).Description("The Id of the Category.");
1013
Field(x => x.Name).Description("The Name of the Category.");
1114
Field(x => x.Status).Description("The Status of the Category.");

src/Cik.Magazine.CategoryService/Denomalizer/NoSQLStorage.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public NoSqlStorage()
2222
public void Handle(CreateNewCategory message)
2323
{
2424
_log.Info("Creation: start to handle [{0}]", message.GetType().Name);
25+
2526
// TODO: will refactor later
2627
_mongoClient = new MongoClient(new MongoUrl("mongodb://127.0.0.1:27017"));
2728
var db = _mongoClient.GetDatabase("magazine");
@@ -37,14 +38,15 @@ public void Handle(CreateNewCategory message)
3738

3839
col.InsertOne(new CategoryViewResponse
3940
{
40-
Name = message.Name,
41+
Name = message.Name,
4142
Status = message.Status
4243
});
4344
}
4445

4546
public void Handle(DeleteCategory message)
4647
{
4748
_log.Info("Delete: start to handle [{0}]", message.GetType().Name);
49+
4850
// TODO: will refactor later
4951
_mongoClient = new MongoClient(new MongoUrl("mongodb://127.0.0.1:27017"));
5052
var db = _mongoClient.GetDatabase("magazine");
@@ -65,6 +67,7 @@ public void Handle(DeleteCategory message)
6567
public void Handle(UpdateCategory message)
6668
{
6769
_log.Info("Edit: start to handle [{0}]", message.GetType().Name);
70+
6871
// TODO: will refactor later
6972
_mongoClient = new MongoClient(new MongoUrl("mongodb://127.0.0.1:27017"));
7073
var db = _mongoClient.GetDatabase("magazine");

src/Cik.Magazine.CategoryService/Query/CategoryQuery.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
22
using System.IO;
3-
using System.Runtime.Remoting.Contexts;
4-
using System.Threading;
53
using Akka.Actor;
64
using Akka.Event;
7-
using Cik.Magazine.CategoryService.Sagas;
85
using Cik.Magazine.Shared.Queries;
96
using MongoDB.Driver;
107

@@ -15,6 +12,7 @@ public class CategoryQuery : TypedActor,
1512
IHandle<CategoryViewRequest>
1613
{
1714
private readonly ILoggingAdapter _log;
15+
1816
// TODO: will refactor later
1917
private readonly MongoClient _mongoClient = new MongoClient(new MongoUrl("mongodb://127.0.0.1:27017"));
2018

0 commit comments

Comments
 (0)