Fix GraphQL Implementation and also UI Playground and add supports for Oracle Provider using EF Core ...
This commit is contained in:
@@ -24,6 +24,6 @@ namespace xDataService.Configuration
|
|||||||
/// Holds Seeding items ...
|
/// Holds Seeding items ...
|
||||||
/// nameof(TEntity) => TEntity
|
/// nameof(TEntity) => TEntity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IDictionary<string, List<dynamic>> SeedItems { get; set; } = new Dictionary<string, List<dynamic>>();
|
public IDictionary<string, List<object>> SeedItems { get; set; } = new Dictionary<string, List<object>>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ namespace xDataService.Constants {
|
|||||||
None,
|
None,
|
||||||
MySQL,
|
MySQL,
|
||||||
SQLite,
|
SQLite,
|
||||||
|
Oracle,
|
||||||
SQLServer,
|
SQLServer,
|
||||||
MongoDB,
|
MongoDB,
|
||||||
}
|
}
|
||||||
@@ -16,8 +17,9 @@ namespace xDataService.Constants {
|
|||||||
public partial struct ProviderType {
|
public partial struct ProviderType {
|
||||||
public const string MySQL = "MYSQL";
|
public const string MySQL = "MYSQL";
|
||||||
public const string SQLite = "SQLITE";
|
public const string SQLite = "SQLITE";
|
||||||
public const string SQLServer = "SQLSERVER";
|
public const string Oracle = "ORACLE";
|
||||||
public const string MongoDB = "MONGODB";
|
public const string MongoDB = "MONGODB";
|
||||||
|
public const string SQLServer = "SQLSERVER";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+42
-10
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using GraphQL.Server.Ui.Playground;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@@ -45,10 +46,24 @@ namespace xDataService.DI
|
|||||||
.ForEach(db =>
|
.ForEach(db =>
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// TODO: Fix this ...
|
var seedItemsSectionName = $"{ConfigurationNodeNames.DATA_SERVICE_NODE}:{nameof(XDataServiceConfiguration.Databases)}:{db.Key}:{nameof(XDataBaseConfiguration.SeedItems)}";
|
||||||
var sectionName = $"{ConfigurationNodeNames.DATA_SERVICE_NODE}:{nameof(XDataServiceConfiguration.Databases)}:{db.Key}:{nameof(XDataBaseConfiguration.SeedItems)}";
|
var section = source.GetSection(seedItemsSectionName);
|
||||||
// var seedItems = source.GetSectionAsDictionary(sectionName);
|
var sectionJson = source.GetSectionAsJson(seedItemsSectionName);
|
||||||
// db.Value.SeedItems = seedItems;
|
var sectionDict = sectionJson.FromJSON<Dictionary<string, List<object>>>();
|
||||||
|
if (!sectionDict.IsNull() &&
|
||||||
|
sectionDict.Values.HasChild())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
sectionDict
|
||||||
|
.Keys
|
||||||
|
.ToList()
|
||||||
|
.ForEach(entity =>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Setting Values to Result ...
|
||||||
|
result.Databases[db.Key].SeedItems[entity] = sectionDict[entity];
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +263,8 @@ namespace xDataService.DI
|
|||||||
public static void UseXDatabase(
|
public static void UseXDatabase(
|
||||||
this IApplicationBuilder source,
|
this IApplicationBuilder source,
|
||||||
XDatabaseDescriptor descriptor,
|
XDatabaseDescriptor descriptor,
|
||||||
bool isDevelopmentEnvironment = false
|
bool isDevelopmentEnvironment = false,
|
||||||
|
GraphQLPlaygroundOptions options = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -265,9 +281,9 @@ namespace xDataService.DI
|
|||||||
|
|
||||||
//
|
//
|
||||||
var withPlayground = false;
|
var withPlayground = false;
|
||||||
|
var isGraphConfigured = false;
|
||||||
if (isDevelopmentEnvironment)
|
if (isDevelopmentEnvironment)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
withPlayground = true;
|
withPlayground = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +313,7 @@ namespace xDataService.DI
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Check Seeder Exists ...
|
// Check Seeder Exists ...
|
||||||
|
// Execute Seeding Data Task if Exists ...
|
||||||
isValid = r.HasSeeder();
|
isValid = r.HasSeeder();
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
@@ -312,7 +329,8 @@ namespace xDataService.DI
|
|||||||
// Seeding ...
|
// Seeding ...
|
||||||
seeder
|
seeder
|
||||||
.Seed()
|
.Seed()
|
||||||
.RunTask();
|
.GetAwaiter()
|
||||||
|
.GetResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +341,10 @@ namespace xDataService.DI
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Use WebSockets ...
|
// Use WebSockets ...
|
||||||
source.UseWebSockets();
|
if (!isGraphConfigured)
|
||||||
|
{
|
||||||
|
source.UseWebSockets();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inject GraphQL Type Helper ...
|
// Inject GraphQL Type Helper ...
|
||||||
@@ -332,7 +353,9 @@ namespace xDataService.DI
|
|||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
string graphPath = helper.GetGraphQLPath();
|
string graphPath = $"{helper.GetGraphQLPath()}";
|
||||||
|
// string graphPath = $"{dataServiceConfiguration.GraphQLBasePath}{helper.GetGraphQLPath()}";
|
||||||
|
graphPath = $"{helper.GetGraphQLPath()}";
|
||||||
typeof(XDataServiceHelper).InvokeGenericMethod(
|
typeof(XDataServiceHelper).InvokeGenericMethod(
|
||||||
methodName: "UseXGraphQL",
|
methodName: "UseXGraphQL",
|
||||||
runtimeTypes: [
|
runtimeTypes: [
|
||||||
@@ -352,6 +375,15 @@ namespace xDataService.DI
|
|||||||
null
|
null
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Log($"Register GraphQL: {graphPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!isGraphConfigured)
|
||||||
|
{
|
||||||
|
isGraphConfigured = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,16 +11,17 @@ using xModels.Base;
|
|||||||
|
|
||||||
namespace xDataService.GraphQL
|
namespace xDataService.GraphQL
|
||||||
{
|
{
|
||||||
public abstract class XBaseGraphQLQuery : ObjectGraphType, IXBaseGraphQLQuery { }
|
public abstract class XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey> : ObjectGraphType, IXBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||||
|
|
||||||
public abstract class XBaseGraphQLQuery<TEntity, TKey> : XBaseGraphQLQuery, IXBaseGraphQLQuery<TEntity, TKey>
|
|
||||||
where TEntity : XBaseEntity<TKey>
|
where TEntity : XBaseEntity<TKey>
|
||||||
|
where TGraph : IGraphType
|
||||||
|
where TGraphKey : IGraphType
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
protected readonly XDataServiceConfiguration configuration;
|
protected readonly XDataServiceConfiguration configuration;
|
||||||
protected readonly IXBaseRepository<TEntity, TKey> repository;
|
protected readonly IXBaseRepository<TEntity, TKey> repository;
|
||||||
protected readonly IXBaseGraphQLTypeHelper<TEntity, TKey> helper;
|
protected readonly IXBaseGraphQLTypeHelper<TEntity, TKey> helper;
|
||||||
|
|
||||||
|
//
|
||||||
public XBaseGraphQLQuery(
|
public XBaseGraphQLQuery(
|
||||||
XDataServiceConfiguration configuration,
|
XDataServiceConfiguration configuration,
|
||||||
IXBaseRepository<TEntity, TKey> repository,
|
IXBaseRepository<TEntity, TKey> repository,
|
||||||
@@ -34,25 +35,7 @@ namespace xDataService.GraphQL
|
|||||||
|
|
||||||
//
|
//
|
||||||
Name = GetType().Name;
|
Name = GetType().Name;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract class XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey> : XBaseGraphQLQuery<TEntity, TKey>, IXBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
||||||
where TEntity : XBaseEntity<TKey>
|
|
||||||
where TGraph : IGraphType
|
|
||||||
where TGraphKey : IGraphType
|
|
||||||
{
|
|
||||||
//
|
|
||||||
public XBaseGraphQLQuery(
|
|
||||||
XDataServiceConfiguration configuration,
|
|
||||||
IXBaseRepository<TEntity, TKey> repository,
|
|
||||||
IXBaseGraphQLTypeHelper<TEntity, TKey> helper
|
|
||||||
) : base(
|
|
||||||
helper: helper,
|
|
||||||
repository: repository,
|
|
||||||
configuration: configuration
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
//
|
||||||
#region Retrieve ...
|
#region Retrieve ...
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -5,94 +5,52 @@ using xModels.Base;
|
|||||||
|
|
||||||
namespace xDataService.GraphQL
|
namespace xDataService.GraphQL
|
||||||
{
|
{
|
||||||
public abstract class XBaseGraphQLTypeHelper : IXBaseGraphQLTypeHelper
|
public abstract class XBaseGraphQLTypeHelper<TEntity, TKey> : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
where TEntity : XBaseEntity<TKey>
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
protected readonly XDataServiceConfiguration configuration;
|
private readonly XDataServiceConfiguration configuration;
|
||||||
|
|
||||||
//
|
//
|
||||||
public XBaseGraphQLTypeHelper(
|
public XBaseGraphQLTypeHelper(
|
||||||
XDataServiceConfiguration configuration
|
XDataServiceConfiguration configuration = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract string GetInQuerySingleName();
|
//
|
||||||
|
|
||||||
public abstract string GetInQueryCollectionName();
|
public abstract string GetInQueryCollectionName();
|
||||||
|
|
||||||
//
|
public abstract string GetInQuerySingleName();
|
||||||
#region Actions ...
|
|
||||||
public virtual string GetCountName()
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string GetExistsName()
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string GetFindManyName()
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string GetFindOneName()
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string GetGraphQLPath(string baseGraphPath = null)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string GetQueryName()
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract class XBaseGraphQLTypeHelper<TEntity, TKey> : XBaseGraphQLTypeHelper, IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
||||||
where TEntity : XBaseEntity<TKey>
|
|
||||||
{
|
|
||||||
//
|
|
||||||
public XBaseGraphQLTypeHelper(
|
|
||||||
XDataServiceConfiguration configuration = null
|
|
||||||
) : base(configuration)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
#region Actions ...
|
public string GetFindOneName()
|
||||||
public override string GetFindOneName()
|
|
||||||
{
|
{
|
||||||
return $"find{GetInQuerySingleName().ToNormalString().Capitalize()}";
|
return $"find{GetInQuerySingleName().ToNormalString().Capitalize()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetFindManyName()
|
public string GetFindManyName()
|
||||||
{
|
{
|
||||||
return $"find{GetInQueryCollectionName().ToNormalString().Capitalize()}";
|
return $"find{GetInQueryCollectionName().ToNormalString().Capitalize()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetQueryName()
|
public string GetQueryName()
|
||||||
{
|
{
|
||||||
return $"query{GetInQueryCollectionName().ToNormalString().Capitalize()}";
|
return $"query{GetInQueryCollectionName().ToNormalString().Capitalize()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetCountName()
|
public string GetCountName()
|
||||||
{
|
{
|
||||||
return $"count{GetInQueryCollectionName().ToNormalString().Capitalize()}";
|
return $"count{GetInQueryCollectionName().ToNormalString().Capitalize()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetExistsName()
|
public string GetExistsName()
|
||||||
{
|
{
|
||||||
return $"exists{GetInQuerySingleName().ToNormalString().Capitalize()}";
|
return $"exists{GetInQuerySingleName().ToNormalString().Capitalize()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetGraphQLPath(string baseGraphPath = null)
|
public string GetGraphQLPath(string baseGraphPath = null)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
baseGraphPath = baseGraphPath.IsNullOrEmpty() ?
|
baseGraphPath = baseGraphPath.IsNullOrEmpty() ?
|
||||||
@@ -111,6 +69,5 @@ namespace xDataService.GraphQL
|
|||||||
//
|
//
|
||||||
return $"{basePath}/{GetInQueryCollectionName().ToNormalString()}";
|
return $"{basePath}/{GetInQueryCollectionName().ToNormalString()}";
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+461
-185
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GraphQL;
|
||||||
using GraphQL.Server;
|
using GraphQL.Server;
|
||||||
using GraphQL.Server.Ui.Playground;
|
using GraphQL.Server.Ui.Playground;
|
||||||
using GraphQL.Types;
|
using GraphQL.Types;
|
||||||
@@ -83,6 +84,21 @@ namespace xDataService.Helpers
|
|||||||
}, lifetime);
|
}, lifetime);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Oracle ...
|
||||||
|
case XDbProviders.Oracle:
|
||||||
|
//
|
||||||
|
source.AddEntityFrameworkOracle();
|
||||||
|
source.AddDbContext<TContext>(cfg =>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
cfg.UseOracle(
|
||||||
|
databaseDescriptor.ConnectionString,
|
||||||
|
databaseDescriptor.OptionsBuilder
|
||||||
|
);
|
||||||
|
}, lifetime);
|
||||||
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
// SQLServer ...
|
// SQLServer ...
|
||||||
case XDbProviders.SQLServer:
|
case XDbProviders.SQLServer:
|
||||||
@@ -153,6 +169,7 @@ namespace xDataService.Helpers
|
|||||||
isValid =
|
isValid =
|
||||||
databaseDescriptor.Provider == XDbProviders.MySQL ||
|
databaseDescriptor.Provider == XDbProviders.MySQL ||
|
||||||
databaseDescriptor.Provider == XDbProviders.SQLite ||
|
databaseDescriptor.Provider == XDbProviders.SQLite ||
|
||||||
|
databaseDescriptor.Provider == XDbProviders.Oracle ||
|
||||||
databaseDescriptor.Provider == XDbProviders.SQLServer;
|
databaseDescriptor.Provider == XDbProviders.SQLServer;
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
@@ -1223,22 +1240,118 @@ namespace xDataService.Helpers
|
|||||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
// Validate Args ...
|
||||||
var isValid = repositoryDescriptor.IsValid();
|
var isValid = repositoryDescriptor.IsValid();
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Chck Seeders ...
|
||||||
|
isValid = repositoryDescriptor.HasSeeder();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// GraphQL ...
|
// GraphQL ...
|
||||||
isValid = repositoryDescriptor.HasGraphSupport();
|
isValid = repositoryDescriptor.HasGraphSupport();
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||||
source,
|
// source,
|
||||||
repositoryDescriptor
|
// repositoryDescriptor
|
||||||
);
|
// );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Repository ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="repositoryDescriptor"></param>
|
||||||
|
/// <param name="lifetime"></param>
|
||||||
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
|
/// <typeparam name="TKey"></typeparam>
|
||||||
|
/// <typeparam name="TKeyGeneratorService"></typeparam>
|
||||||
|
/// <typeparam name="TKeyGeneratorImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TEventsService"></typeparam>
|
||||||
|
/// <typeparam name="TEventsImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TGraph"></typeparam>
|
||||||
|
/// <typeparam name="TGraphKey"></typeparam>
|
||||||
|
/// <typeparam name="TGraphQuery"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperService"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TGraphSchema"></typeparam>
|
||||||
|
/// <typeparam name="TRepositoryService"></typeparam>
|
||||||
|
/// <typeparam name="TRepositoryImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TSeederService"></typeparam>
|
||||||
|
/// <typeparam name="TSeederImplementation"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void UseXRepository<
|
||||||
|
TEntity,
|
||||||
|
TKey,
|
||||||
|
TKeyGeneratorService,
|
||||||
|
TKeyGeneratorImplementation,
|
||||||
|
TEventsService,
|
||||||
|
TEventsImplementation,
|
||||||
|
TGraph,
|
||||||
|
TGraphKey,
|
||||||
|
TGraphQuery,
|
||||||
|
TGraphTypeHelperService,
|
||||||
|
TGraphTypeHelperImplementation,
|
||||||
|
TGraphSchema,
|
||||||
|
TRepositoryService,
|
||||||
|
TRepositoryImplementation,
|
||||||
|
TSeederService,
|
||||||
|
TSeederImplementation
|
||||||
|
>(
|
||||||
|
IApplicationBuilder source,
|
||||||
|
XInMemoryRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TSeederService, TSeederImplementation> repositoryDescriptor
|
||||||
|
)
|
||||||
|
where TGraphSchema : Schema
|
||||||
|
where TGraphKey : IGraphType
|
||||||
|
where TEntity : XBaseEntity<TKey>
|
||||||
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
||||||
|
where TSeederService : IXBaseDbSeeder<TEntity, TKey>
|
||||||
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<TEntity, TKey>
|
||||||
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
||||||
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
||||||
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
||||||
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
||||||
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
where TRepositoryImplementation : XBaseInMemoryRepository<TEntity, TKey>
|
||||||
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||||
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
var isValid = repositoryDescriptor.IsValid();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Chck Seeders ...
|
||||||
|
isValid = repositoryDescriptor.HasSeeder();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// GraphQL ...
|
||||||
|
isValid = repositoryDescriptor.HasGraphSupport();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||||
|
// source,
|
||||||
|
// repositoryDescriptor
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1297,101 +1410,311 @@ namespace xDataService.Helpers
|
|||||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
// Validate Args ...
|
||||||
var isValid = repositoryDescriptor.IsValid();
|
var isValid = repositoryDescriptor.IsValid();
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Chck Seeders ...
|
||||||
|
isValid = repositoryDescriptor.HasSeeder();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// GraphQL ...
|
// GraphQL ...
|
||||||
isValid = repositoryDescriptor.HasGraphSupport();
|
isValid = repositoryDescriptor.HasGraphSupport();
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||||
source,
|
// source,
|
||||||
repositoryDescriptor
|
// repositoryDescriptor
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// <summary>
|
/// <summary>
|
||||||
// /// Register Repository ...
|
/// Register Repository ...
|
||||||
// /// </summary>
|
/// </summary>
|
||||||
// /// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
// /// <param name="repositoryDescriptor"></param>
|
/// <param name="repositoryDescriptor"></param>
|
||||||
// /// <typeparam name="TEntity"></typeparam>
|
/// <param name="lifetime"></param>
|
||||||
// /// <typeparam name="TKey"></typeparam>
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
// /// <typeparam name="TKeyGeneratorService"></typeparam>
|
/// <typeparam name="TKey"></typeparam>
|
||||||
// /// <typeparam name="TKeyGeneratorImplementation"></typeparam>
|
/// <typeparam name="TKeyGeneratorService"></typeparam>
|
||||||
// /// <typeparam name="TEventsService"></typeparam>
|
/// <typeparam name="TKeyGeneratorImplementation"></typeparam>
|
||||||
// /// <typeparam name="TEventsImplementation"></typeparam>
|
/// <typeparam name="TEventsService"></typeparam>
|
||||||
// /// <typeparam name="TGraph"></typeparam>
|
/// <typeparam name="TEventsImplementation"></typeparam>
|
||||||
// /// <typeparam name="TGraphKey"></typeparam>
|
/// <typeparam name="TGraph"></typeparam>
|
||||||
// /// <typeparam name="TGraphQuery"></typeparam>
|
/// <typeparam name="TGraphKey"></typeparam>
|
||||||
// /// <typeparam name="TGraphTypeHelperService"></typeparam>
|
/// <typeparam name="TGraphQuery"></typeparam>
|
||||||
// /// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
|
/// <typeparam name="TGraphTypeHelperService"></typeparam>
|
||||||
// /// <typeparam name="TGraphSchema"></typeparam>
|
/// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
|
||||||
// /// <typeparam name="TRepositoryService"></typeparam>
|
/// <typeparam name="TGraphSchema"></typeparam>
|
||||||
// /// <typeparam name="TRepositoryImplementation"></typeparam>
|
/// <typeparam name="TRepositoryService"></typeparam>
|
||||||
// /// <typeparam name="TContext"></typeparam>
|
/// <typeparam name="TRepositoryImplementation"></typeparam>
|
||||||
// /// <returns></returns>
|
/// <typeparam name="TSeederService"></typeparam>
|
||||||
// public static void UseXRepository<
|
/// <typeparam name="TSeederImplementation"></typeparam>
|
||||||
// TEntity,
|
/// <returns></returns>
|
||||||
// TKey,
|
public static void UseXRepository<
|
||||||
// TKeyGeneratorService,
|
TEntity,
|
||||||
// TKeyGeneratorImplementation,
|
TKey,
|
||||||
// TEventsService,
|
TKeyGeneratorService,
|
||||||
// TEventsImplementation,
|
TKeyGeneratorImplementation,
|
||||||
// TGraph,
|
TEventsService,
|
||||||
// TGraphKey,
|
TEventsImplementation,
|
||||||
// TGraphQuery,
|
TGraph,
|
||||||
// TGraphTypeHelperService,
|
TGraphKey,
|
||||||
// TGraphTypeHelperImplementation,
|
TGraphQuery,
|
||||||
// TGraphSchema,
|
TGraphTypeHelperService,
|
||||||
// TRepositoryService,
|
TGraphTypeHelperImplementation,
|
||||||
// TRepositoryImplementation,
|
TGraphSchema,
|
||||||
// TContext
|
TRepositoryService,
|
||||||
// >(
|
TRepositoryImplementation,
|
||||||
// IApplicationBuilder source,
|
TSeederService,
|
||||||
// XEFRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TContext> repositoryDescriptor
|
TSeederImplementation
|
||||||
// )
|
>(
|
||||||
// where TGraphSchema : Schema
|
IApplicationBuilder source,
|
||||||
// where TContext : XDbContext
|
XMongoRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TSeederService, TSeederImplementation> repositoryDescriptor
|
||||||
// where TGraphKey : IGraphType
|
)
|
||||||
// where TEntity : XBaseEntity<TKey>
|
where TGraphSchema : Schema
|
||||||
// where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
where TGraphKey : IGraphType
|
||||||
// where TEventsService : IXBaseRepositoryEvents<TEntity>
|
where TEntity : XBaseEntity<TKey>
|
||||||
// where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
||||||
// where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
where TSeederService : IXBaseDbSeeder<TEntity, TKey>
|
||||||
// where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
||||||
// where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
where TSeederImplementation : XBaseDbSeeder<TEntity, TKey>
|
||||||
// where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
||||||
// where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
||||||
// where TRepositoryImplementation : XBaseEFRepository<TEntity, TKey, TContext>
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
||||||
// where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
||||||
// {
|
where TRepositoryImplementation : XBaseMongoRepository<TEntity, TKey>
|
||||||
// //
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
// var isValid = repositoryDescriptor.IsValid();
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||||
// if (!isValid)
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
// {
|
{
|
||||||
// return;
|
//
|
||||||
// }
|
// Validate Args ...
|
||||||
|
var isValid = repositoryDescriptor.IsValid();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// //
|
//
|
||||||
// // GraphQL ...
|
// Chck Seeders ...
|
||||||
// isValid = repositoryDescriptor.HasGraphSupport();
|
isValid = repositoryDescriptor.HasSeeder();
|
||||||
// if (isValid)
|
if (isValid)
|
||||||
// {
|
{
|
||||||
// //
|
}
|
||||||
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
|
||||||
// source,
|
|
||||||
// repositoryDescriptor
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// GraphQL ...
|
||||||
|
isValid = repositoryDescriptor.HasGraphSupport();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||||
|
// source,
|
||||||
|
// repositoryDescriptor
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Repository ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="repositoryDescriptor"></param>
|
||||||
|
/// <param name="lifetime"></param>
|
||||||
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
|
/// <typeparam name="TKey"></typeparam>
|
||||||
|
/// <typeparam name="TKeyGeneratorService"></typeparam>
|
||||||
|
/// <typeparam name="TKeyGeneratorImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TEventsService"></typeparam>
|
||||||
|
/// <typeparam name="TEventsImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TGraph"></typeparam>
|
||||||
|
/// <typeparam name="TGraphKey"></typeparam>
|
||||||
|
/// <typeparam name="TGraphQuery"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperService"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TGraphSchema"></typeparam>
|
||||||
|
/// <typeparam name="TRepositoryService"></typeparam>
|
||||||
|
/// <typeparam name="TRepositoryImplementation"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void UseXRepository<
|
||||||
|
TEntity,
|
||||||
|
TKey,
|
||||||
|
TKeyGeneratorService,
|
||||||
|
TKeyGeneratorImplementation,
|
||||||
|
TEventsService,
|
||||||
|
TEventsImplementation,
|
||||||
|
TGraph,
|
||||||
|
TGraphKey,
|
||||||
|
TGraphQuery,
|
||||||
|
TGraphTypeHelperService,
|
||||||
|
TGraphTypeHelperImplementation,
|
||||||
|
TGraphSchema,
|
||||||
|
TRepositoryService,
|
||||||
|
TRepositoryImplementation,
|
||||||
|
TContext
|
||||||
|
>(
|
||||||
|
IApplicationBuilder source,
|
||||||
|
XEFRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TContext> repositoryDescriptor
|
||||||
|
)
|
||||||
|
where TGraphSchema : Schema
|
||||||
|
where TContext : XDbContext
|
||||||
|
where TGraphKey : IGraphType
|
||||||
|
where TEntity : XBaseEntity<TKey>
|
||||||
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
||||||
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
||||||
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
||||||
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
||||||
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
||||||
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
||||||
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||||
|
where TRepositoryImplementation : XBaseEFRepository<TEntity, TKey, TContext>
|
||||||
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
var isValid = repositoryDescriptor.IsValid();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Chck Seeders ...
|
||||||
|
isValid = repositoryDescriptor.HasSeeder();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// GraphQL ...
|
||||||
|
isValid = repositoryDescriptor.HasGraphSupport();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
// //
|
||||||
|
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||||
|
// source,
|
||||||
|
// repositoryDescriptor
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register Repository ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="repositoryDescriptor"></param>
|
||||||
|
/// <param name="lifetime"></param>
|
||||||
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
|
/// <typeparam name="TKey"></typeparam>
|
||||||
|
/// <typeparam name="TKeyGeneratorService"></typeparam>
|
||||||
|
/// <typeparam name="TKeyGeneratorImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TEventsService"></typeparam>
|
||||||
|
/// <typeparam name="TEventsImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TGraph"></typeparam>
|
||||||
|
/// <typeparam name="TGraphKey"></typeparam>
|
||||||
|
/// <typeparam name="TGraphQuery"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperService"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TGraphSchema"></typeparam>
|
||||||
|
/// <typeparam name="TRepositoryService"></typeparam>
|
||||||
|
/// <typeparam name="TRepositoryImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TSeederService"></typeparam>
|
||||||
|
/// <typeparam name="TSeederImplementation"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void UseXRepository<
|
||||||
|
TEntity,
|
||||||
|
TKey,
|
||||||
|
TKeyGeneratorService,
|
||||||
|
TKeyGeneratorImplementation,
|
||||||
|
TEventsService,
|
||||||
|
TEventsImplementation,
|
||||||
|
TGraph,
|
||||||
|
TGraphKey,
|
||||||
|
TGraphQuery,
|
||||||
|
TGraphTypeHelperService,
|
||||||
|
TGraphTypeHelperImplementation,
|
||||||
|
TGraphSchema,
|
||||||
|
TRepositoryService,
|
||||||
|
TRepositoryImplementation,
|
||||||
|
TContext,
|
||||||
|
TSeederService,
|
||||||
|
TSeederImplementation
|
||||||
|
>(
|
||||||
|
IApplicationBuilder source,
|
||||||
|
XEFRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TContext, TSeederService, TSeederImplementation> repositoryDescriptor
|
||||||
|
)
|
||||||
|
where TGraphSchema : Schema
|
||||||
|
where TContext : XDbContext
|
||||||
|
where TGraphKey : IGraphType
|
||||||
|
where TEntity : XBaseEntity<TKey>
|
||||||
|
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
||||||
|
where TSeederService : IXBaseDbSeeder<TEntity, TKey>
|
||||||
|
where TEventsService : IXBaseRepositoryEvents<TEntity>
|
||||||
|
where TSeederImplementation : XBaseDbSeeder<TEntity, TKey>
|
||||||
|
where TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
||||||
|
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
||||||
|
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
||||||
|
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
||||||
|
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||||
|
where TRepositoryImplementation : XBaseEFRepository<TEntity, TKey, TContext>
|
||||||
|
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate Args ...
|
||||||
|
var isValid = repositoryDescriptor.IsValid();
|
||||||
|
if (!isValid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Chck Seeders ...
|
||||||
|
isValid = repositoryDescriptor.HasSeeder();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// GraphQL ...
|
||||||
|
isValid = repositoryDescriptor.HasGraphSupport();
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
// //
|
||||||
|
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||||
|
// source,
|
||||||
|
// repositoryDescriptor
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use GraphQL ...
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
|
/// <typeparam name="TKey"></typeparam>
|
||||||
|
/// <typeparam name="TGraph"></typeparam>
|
||||||
|
/// <typeparam name="TGraphKey"></typeparam>
|
||||||
|
/// <typeparam name="TGraphQuery"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperService"></typeparam>
|
||||||
|
/// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
|
||||||
|
/// <typeparam name="TGraphSchema"></typeparam>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <param name="graphPath"></param>
|
||||||
|
/// <param name="withPlayGround"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
public static void UseXGraphQL<
|
public static void UseXGraphQL<
|
||||||
TEntity,
|
TEntity,
|
||||||
TKey,
|
TKey,
|
||||||
@@ -1422,6 +1745,14 @@ namespace xDataService.Helpers
|
|||||||
//
|
//
|
||||||
if (withPlayGround)
|
if (withPlayGround)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
if (options.IsNull())
|
||||||
|
{
|
||||||
|
options = new GraphQLPlaygroundOptions();
|
||||||
|
}
|
||||||
|
options.Path = "/ui/playground";
|
||||||
|
|
||||||
|
//
|
||||||
source.UseGraphQLPlayground(options);
|
source.UseGraphQLPlayground(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1600,43 +1931,13 @@ namespace xDataService.Helpers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Register Graph Schema ...
|
|
||||||
source.Add(
|
|
||||||
new ServiceDescriptor(
|
|
||||||
repositoryDescriptor.GraphSchema,
|
|
||||||
repositoryDescriptor.GraphSchema,
|
|
||||||
lifetime
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register Graph Query ...
|
|
||||||
source.Add(
|
|
||||||
new ServiceDescriptor(
|
|
||||||
repositoryDescriptor.GraphQuery,
|
|
||||||
repositoryDescriptor.GraphQuery,
|
|
||||||
lifetime
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Register Graph Type Helper ...
|
|
||||||
source.Add(
|
|
||||||
new ServiceDescriptor(
|
|
||||||
repositoryDescriptor.GraphTypeHelperService,
|
|
||||||
repositoryDescriptor.GraphTypeHelperImplementation,
|
|
||||||
lifetime: ServiceLifetime.Singleton
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Graph Type ...
|
// Register Graph Type ...
|
||||||
source.Add(
|
source.Add(
|
||||||
new ServiceDescriptor(
|
new ServiceDescriptor(
|
||||||
repositoryDescriptor.GraphType,
|
lifetime: ServiceLifetime.Singleton,
|
||||||
repositoryDescriptor.GraphType,
|
serviceType: repositoryDescriptor.GraphType,
|
||||||
ServiceLifetime.Singleton
|
implementationType: repositoryDescriptor.GraphType
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1644,19 +1945,60 @@ namespace xDataService.Helpers
|
|||||||
// Register Graph Events ...
|
// Register Graph Events ...
|
||||||
source.Add(
|
source.Add(
|
||||||
new ServiceDescriptor(
|
new ServiceDescriptor(
|
||||||
typeof(XBaseGraphQLEventType<TEntity, TKey, TGraph>),
|
lifetime: ServiceLifetime.Singleton,
|
||||||
typeof(XBaseGraphQLEventType<TEntity, TKey, TGraph>),
|
serviceType: typeof(XBaseGraphQLEventType<TEntity, TKey, TGraph>),
|
||||||
ServiceLifetime.Singleton
|
implementationType: typeof(XBaseGraphQLEventType<TEntity, TKey, TGraph>)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Graph Type Helper ...
|
||||||
|
source.Add(
|
||||||
|
new ServiceDescriptor(
|
||||||
|
lifetime: ServiceLifetime.Singleton,
|
||||||
|
serviceType: repositoryDescriptor.GraphTypeHelperService,
|
||||||
|
implementationType: repositoryDescriptor.GraphTypeHelperImplementation
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Graph Query ...
|
||||||
|
source.Add(
|
||||||
|
new ServiceDescriptor(
|
||||||
|
lifetime: lifetime,
|
||||||
|
serviceType: repositoryDescriptor.GraphQuery,
|
||||||
|
implementationType: repositoryDescriptor.GraphQuery
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Graph Schema ...
|
||||||
|
source.Add(
|
||||||
|
new ServiceDescriptor(
|
||||||
|
serviceType: repositoryDescriptor.GraphSchema,
|
||||||
|
implementationType: repositoryDescriptor.GraphSchema,
|
||||||
|
lifetime: lifetime
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
source.AddSingleton<IDocumentExecuter, DocumentExecuter>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Graph Type Schema ...
|
// Register Graph Type Schema ...
|
||||||
var builder = source.GetRegisteredService<IGraphQLBuilder>();
|
var builder = source.GetRegisteredService<IGraphQLBuilder>();
|
||||||
if (builder.IsNull())
|
if (builder.IsNull())
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Action<GraphQLOptions> options = x => { };
|
Action<GraphQLOptions> options = x =>
|
||||||
|
{
|
||||||
|
//
|
||||||
|
x.EnableMetrics = true;
|
||||||
|
x.UnhandledExceptionDelegate = context =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("XGraphQL Error: " + context.OriginalException.Message);
|
||||||
|
};
|
||||||
|
};
|
||||||
builder = source.AddGraphQL(options)
|
builder = source.AddGraphQL(options)
|
||||||
.AddNewtonsoftJson(deserializerSettings => { }, serializerSettings => { })
|
.AddNewtonsoftJson(deserializerSettings => { }, serializerSettings => { })
|
||||||
.AddWebSockets()
|
.AddWebSockets()
|
||||||
@@ -1665,72 +2007,6 @@ namespace xDataService.Helpers
|
|||||||
}
|
}
|
||||||
builder.AddGraphTypes(repositoryDescriptor.GraphSchema);
|
builder.AddGraphTypes(repositoryDescriptor.GraphSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Use GraphQL Middleware ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source"></param>
|
|
||||||
/// <param name="repositoryDescriptor"></param>
|
|
||||||
/// <param name="lifetime"></param>
|
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
|
||||||
/// <typeparam name="TKey"></typeparam>
|
|
||||||
/// <typeparam name="TGraph"></typeparam>
|
|
||||||
/// <typeparam name="TGraphKey"></typeparam>
|
|
||||||
/// <typeparam name="TGraphQuery"></typeparam>
|
|
||||||
/// <typeparam name="TGraphTypeHelperService"></typeparam>
|
|
||||||
/// <typeparam name="TGraphTypeHelperImplementation"></typeparam>
|
|
||||||
/// <typeparam name="TGraphSchema"></typeparam>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static void UseXGraphQL<
|
|
||||||
TEntity,
|
|
||||||
TKey,
|
|
||||||
TGraph,
|
|
||||||
TGraphKey,
|
|
||||||
TGraphQuery,
|
|
||||||
TGraphTypeHelperService,
|
|
||||||
TGraphTypeHelperImplementation,
|
|
||||||
TGraphSchema
|
|
||||||
>(
|
|
||||||
IApplicationBuilder source,
|
|
||||||
XRepositoryDescriptor<TEntity, TKey> repositoryDescriptor
|
|
||||||
)
|
|
||||||
where TGraphSchema : Schema
|
|
||||||
where TGraphKey : IGraphType
|
|
||||||
where TEntity : XBaseEntity<TKey>
|
|
||||||
where TGraph : XBaseGraphObjectType<TEntity, TKey>
|
|
||||||
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
|
||||||
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
|
||||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Validate ...
|
|
||||||
var isValid =
|
|
||||||
!source.IsNull() &&
|
|
||||||
!repositoryDescriptor.IsNull() &&
|
|
||||||
!repositoryDescriptor.GraphType.IsNull() &&
|
|
||||||
!repositoryDescriptor.GraphQuery.IsNull() &&
|
|
||||||
!repositoryDescriptor.GraphSchema.IsNull() &&
|
|
||||||
!repositoryDescriptor.GraphTypeKey.IsNull() &&
|
|
||||||
!repositoryDescriptor.GraphTypeHelperService.IsNull() &&
|
|
||||||
!repositoryDescriptor.GraphTypeHelperImplementation.IsNull();
|
|
||||||
if (!isValid)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Create an Scope for Services Acces ...
|
|
||||||
using (var scope = source.ApplicationServices.CreateScope())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Inject GraphQL Type Helper ...
|
|
||||||
var helper = scope.ServiceProvider.GetService<TGraphTypeHelperService>();
|
|
||||||
|
|
||||||
//
|
|
||||||
source.UseGraphQL<TGraphSchema>(helper.GetGraphQLPath());
|
|
||||||
source.UseGraphQLWebSockets<TGraphSchema>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,10 +10,24 @@ namespace xDataService.Interfaces
|
|||||||
public interface IXBaseDbSeeder<TEntity, TKey>
|
public interface IXBaseDbSeeder<TEntity, TKey>
|
||||||
where TEntity : XBaseEntity<TKey>
|
where TEntity : XBaseEntity<TKey>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holds Entity Name ...
|
||||||
|
/// </summary>
|
||||||
|
string Entity { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Holds Database Name ...
|
||||||
|
/// </summary>
|
||||||
string Database { get; }
|
string Database { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repository Service for Data Manipulation ...
|
||||||
|
/// </summary>
|
||||||
IXBaseRepository<TEntity, TKey> Repository { get; }
|
IXBaseRepository<TEntity, TKey> Repository { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DataServiceConfiguration ...
|
||||||
|
/// </summary>
|
||||||
XDataServiceConfiguration DataServiceConfiguration { get; }
|
XDataServiceConfiguration DataServiceConfiguration { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -3,13 +3,7 @@ using xModels.Base;
|
|||||||
|
|
||||||
namespace xDataService.Interfaces
|
namespace xDataService.Interfaces
|
||||||
{
|
{
|
||||||
public interface IXBaseGraphQLQuery { }
|
public interface IXBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||||
|
|
||||||
public interface IXBaseGraphQLQuery<TEntity, TKey> : IXBaseGraphQLQuery
|
|
||||||
where TEntity : XBaseEntity<TKey>
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public interface IXBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey> : IXBaseGraphQLQuery<TEntity, TKey>
|
|
||||||
where TEntity : XBaseEntity<TKey>
|
where TEntity : XBaseEntity<TKey>
|
||||||
where TGraph : IGraphType
|
where TGraph : IGraphType
|
||||||
where TGraphKey : IGraphType
|
where TGraphKey : IGraphType
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ using xModels.Base;
|
|||||||
|
|
||||||
namespace xDataService.Interfaces
|
namespace xDataService.Interfaces
|
||||||
{
|
{
|
||||||
public interface IXBaseGraphQLTypeHelper
|
public interface IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||||
|
where TEntity : XBaseEntity<TKey>
|
||||||
{
|
{
|
||||||
string GetInQuerySingleName();
|
string GetInQuerySingleName();
|
||||||
|
|
||||||
string GetInQueryCollectionName();
|
string GetInQueryCollectionName();
|
||||||
|
|
||||||
string GetFindOneName();
|
string GetFindOneName();
|
||||||
@@ -20,8 +21,4 @@ namespace xDataService.Interfaces
|
|||||||
|
|
||||||
string GetGraphQLPath(string baseGraphPath = null);
|
string GetGraphQLPath(string baseGraphPath = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IXBaseGraphQLTypeHelper<TEntity, TKey> : IXBaseGraphQLTypeHelper
|
|
||||||
where TEntity : XBaseEntity<TKey>
|
|
||||||
{ }
|
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -12,29 +13,48 @@ namespace xDataService.Providers
|
|||||||
public abstract class XBaseDbSeeder<TEntity, TKey> : IXBaseDbSeeder<TEntity, TKey>
|
public abstract class XBaseDbSeeder<TEntity, TKey> : IXBaseDbSeeder<TEntity, TKey>
|
||||||
where TEntity : XBaseEntity<TKey>
|
where TEntity : XBaseEntity<TKey>
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
#region Properties ...
|
||||||
|
/// <summary>
|
||||||
|
/// Holds Entity Name ...
|
||||||
|
/// </summary>
|
||||||
|
public string Entity { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Holds Database Name ...
|
||||||
|
/// </summary>
|
||||||
public string Database { get; }
|
public string Database { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repository Service for Data Manipulation ...
|
||||||
|
/// </summary>
|
||||||
public IXBaseRepository<TEntity, TKey> Repository { get; }
|
public IXBaseRepository<TEntity, TKey> Repository { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DataServiceConfiguration ...
|
||||||
|
/// </summary>
|
||||||
public XDataServiceConfiguration DataServiceConfiguration { get; }
|
public XDataServiceConfiguration DataServiceConfiguration { get; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
#region Constructor ...
|
||||||
public XBaseDbSeeder(
|
public XBaseDbSeeder(
|
||||||
|
string entity,
|
||||||
string database,
|
string database,
|
||||||
IXBaseRepository<TEntity, TKey> repository,
|
IXBaseRepository<TEntity, TKey> repository,
|
||||||
XDataServiceConfiguration dataServiceConfiguration
|
XDataServiceConfiguration dataServiceConfiguration
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
this.Entity = entity;
|
||||||
this.Database = database;
|
this.Database = database;
|
||||||
this.Repository = repository;
|
this.Repository = repository;
|
||||||
this.DataServiceConfiguration = dataServiceConfiguration;
|
this.DataServiceConfiguration = dataServiceConfiguration;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public async Task Seed()
|
public async Task Seed()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
var entityName = nameof(TEntity);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Seed ...
|
// Validate Seed ...
|
||||||
var isValid =
|
var isValid =
|
||||||
@@ -45,7 +65,7 @@ namespace xDataService.Providers
|
|||||||
db.Key == Database &&
|
db.Key == Database &&
|
||||||
db.Value.SeedItems
|
db.Value.SeedItems
|
||||||
.Any(si =>
|
.Any(si =>
|
||||||
si.Key == entityName &&
|
si.Key == Entity &&
|
||||||
si.Value.HasChild()));
|
si.Value.HasChild()));
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
@@ -56,7 +76,7 @@ namespace xDataService.Providers
|
|||||||
// Extract Seeding Items ...
|
// Extract Seeding Items ...
|
||||||
var seedItems = DataServiceConfiguration
|
var seedItems = DataServiceConfiguration
|
||||||
.Databases[Database]
|
.Databases[Database]
|
||||||
.SeedItems[entityName]
|
.SeedItems[Entity]
|
||||||
.ToList();
|
.ToList();
|
||||||
foreach (var item in seedItems)
|
foreach (var item in seedItems)
|
||||||
{
|
{
|
||||||
@@ -64,8 +84,9 @@ namespace xDataService.Providers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Try to convert Item to Entity ...
|
var entity = item
|
||||||
var entity = ((object)item).FromDynamicObject<TEntity>();
|
.ToJSON()
|
||||||
|
.FromJSON<TEntity>();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Item Exists or not ...
|
// Check Item Exists or not ...
|
||||||
@@ -100,7 +121,10 @@ namespace xDataService.Providers
|
|||||||
if (!isExist)
|
if (!isExist)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
exists = await Repository.AddAsync(entity);
|
exists = await Repository.AddAsync(
|
||||||
|
item: entity,
|
||||||
|
saveChanges: true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -31,12 +31,12 @@
|
|||||||
<!-- <PackageReference Include="xDashboard.xModels" Version="1.0.0" /> -->
|
<!-- <PackageReference Include="xDashboard.xModels" Version="1.0.0" /> -->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Dependencies -->
|
<!-- MongoDB -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MongoDB.Driver" Version="2.13.2" />
|
<PackageReference Include="MongoDB.Driver" Version="2.13.2" />
|
||||||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- GraphQL -->
|
<!-- GraphQL -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GraphQL" Version="3.0.0.2026" />
|
<PackageReference Include="GraphQL" Version="3.0.0.2026" />
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
<PackageReference Include="MySql.EntityFrameworkCore" Version="3.1.14" />
|
<PackageReference Include="MySql.EntityFrameworkCore" Version="3.1.14" />
|
||||||
|
<PackageReference Include="Oracle.EntityFrameworkCore" Version="3.19.180" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.14" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.14">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.14">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
Reference in New Issue
Block a user