This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(enrolling): add GraphQL support (#239)
- add Serilog request logging - add span enricher for serilog
- Loading branch information
1 parent
3d599cf
commit 16abcfe
Showing
13 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Services/Enrolling/Enrolling.API/graphql/GraphQlErrorFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using HotChocolate; | ||
|
||
namespace OpenCodeFoundation.ESchool.Services.Enrolling.API.Graphql | ||
{ | ||
public class GraphQlErrorFilter | ||
: IErrorFilter | ||
{ | ||
public IError OnError(IError error) | ||
{ | ||
return error.WithMessage( | ||
error.Exception?.Message ?? string.Empty); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Threading.Tasks; | ||
using HotChocolate; | ||
using OpenCodeFoundation.ESchool.Services.Enrolling.API.Application.Commands; | ||
using OpenCodeFoundation.ESchool.Services.Enrolling.Domain.AggregatesModel.EnrollmentAggregate; | ||
using OpenCodeFoundation.ESchool.Services.Enrolling.Infrastructure; | ||
|
||
namespace OpenCodeFoundation.ESchool.Services.Enrolling.API.Graphql | ||
{ | ||
public class Mutation | ||
{ | ||
public async Task<Enrollment> AddEnrollmentAsync( | ||
EnrollmentApplicationCommand input, | ||
[Service] EnrollingContext context) | ||
{ | ||
var enrollment = new Enrollment( | ||
input.Name, | ||
input.Email, | ||
input.Mobile); | ||
|
||
await context.Enrollments.AddAsync(enrollment); | ||
await context.SaveChangesAsync(); | ||
return enrollment; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using HotChocolate; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
using OpenCodeFoundation.ESchool.Services.Enrolling.Domain.AggregatesModel.EnrollmentAggregate; | ||
using OpenCodeFoundation.ESchool.Services.Enrolling.Infrastructure; | ||
|
||
namespace OpenCodeFoundation.ESchool.Services.Enrolling.API.Graphql | ||
{ | ||
public class Query | ||
{ | ||
public async Task<List<Enrollment>> GetEnrollmentsAsync( | ||
[Service] EnrollingContext context, | ||
[Service] ILogger<Query> logger) | ||
{ | ||
var enrollments = await context.Enrollments | ||
.ToListAsync(); | ||
|
||
logger.LogInformation( | ||
"Returning enrollments {EnrollmentCount} with payload {@Enrollment}", | ||
enrollments.Count, | ||
enrollments); | ||
|
||
return enrollments; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters