-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HER-49] Create detections query (#24)
* [HER-49]Add Resolver and IResolver to Creating * [HER-49]Add Resolver and IResolver to Fetching * [HER-49]Add services to Startup * [HER-49]Add field to query * [HER-49]Add provider variable to Schema * [HER-49]Add TDetection * [HER-49]Add missing reference
- Loading branch information
1 parent
221c01e
commit 17f43cc
Showing
8 changed files
with
94 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Presentation.Detection.Common.Types | ||
{ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Business.Detection.Common.Models; | ||
using global::GraphQL.Types; | ||
using Style; | ||
|
||
[SuppressMessage(Category.Default, Check.CA1724, Justification = Reason.Readability)] | ||
public sealed class TDetection : ObjectGraphType<MDetection> | ||
{ | ||
public TDetection() | ||
{ | ||
Field(detection => detection.Id).Description("This is the ID"); | ||
Field(detection => detection.Score).Description("This is the Score"); | ||
Field(detection => detection.Timestamp).Description("This is the Timestamp"); | ||
Field(detection => detection.Class).Description("This is the Class"); | ||
} | ||
} | ||
} |
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,12 @@ | ||
namespace Presentation.Detection.Creating | ||
{ | ||
using System.Collections.Generic; | ||
using Business; | ||
using Business.Detection.Common.Models; | ||
using Business.Detection.Fetching.Commands; | ||
using global::GraphQL; | ||
|
||
public interface IResolver : ICommand<IResolveFieldContext<object>, IEnumerable<MDetection>> | ||
{ | ||
} | ||
} |
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,16 @@ | ||
namespace Presentation.Detection.Creating | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Business.Detection.Common.Models; | ||
using global::GraphQL; | ||
|
||
public class Resolver : IResolver | ||
{ | ||
public IEnumerable<MDetection> Execute(IResolveFieldContext<object> input) => | ||
new[] | ||
{ | ||
new MDetection { Id = 1, Class = "Pet", Score = 60, Timestamp = DateTime.UtcNow }, | ||
}; | ||
} | ||
} |
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,12 @@ | ||
namespace Presentation.Detection.Fetching | ||
{ | ||
using System.Collections.Generic; | ||
using Business; | ||
using Business.Detection.Common.Models; | ||
using Business.Detection.Fetching.Commands; | ||
using global::GraphQL; | ||
|
||
public interface IResolver : ICommand<IResolveFieldContext<object>, IEnumerable<MDetection>> | ||
{ | ||
} | ||
} |
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,16 @@ | ||
namespace Presentation.Detection.Fetching | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using Business.Detection.Common.Models; | ||
using global::GraphQL; | ||
|
||
public class Resolver : IResolver | ||
{ | ||
public IEnumerable<MDetection> Execute(IResolveFieldContext<object> input) => | ||
new[] | ||
{ | ||
new MDetection { Id = 2, Class = "Cardboard", Score = 80, Timestamp = DateTime.UtcNow }, | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,23 @@ | ||
namespace Presentation.GraphQL.Base | ||
{ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using global::GraphQL.Types; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Presentation.Detection.Common.Types; | ||
using Style; | ||
|
||
[SuppressMessage(Category.Default, Check.CA1724, Justification = Reason.Readability)] | ||
|
||
public class Query : ObjectGraphType | ||
{ | ||
public Query() | ||
{ | ||
Name = "Query"; | ||
Field(typeof(StringGraphType), "BasicQuery", "Query description", null, _ => "Query"); | ||
} | ||
} | ||
{ | ||
public Query(IServiceProvider provider) | ||
{ | ||
Name = "query"; | ||
Field(typeof(NonNullGraphType<ListGraphType<NonNullGraphType<TDetection>>>), | ||
"detections", | ||
"Fetch all the existing detections", | ||
resolve: provider.GetService<Detection.Fetching.IResolver>().Execute); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
namespace Presentation.GraphQL.Base | ||
{ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Style; | ||
|
||
[SuppressMessage(Category.Default, Check.CA1724, Justification = Reason.Readability)] | ||
public class Schema : global::GraphQL.Types.Schema | ||
{ | ||
public Schema() | ||
public Schema(IServiceProvider provider) | ||
{ | ||
Mutation = new Mutation(); | ||
|
||
Query = new Query(); | ||
Query = new Query(provider); | ||
} | ||
} | ||
} |
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