add support for Db Seeder, Fix GraphQL Generic Usage ...
This commit is contained in:
+505
-53
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using GraphQL.Server;
|
||||
using GraphQL.Server.Ui.Playground;
|
||||
using GraphQL.Types;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -448,7 +449,7 @@ namespace xDataService.Helpers
|
||||
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
||||
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||
where TRepositoryImplementation : XBaseInMemoryRepositoy<TEntity, TKey>
|
||||
where TRepositoryImplementation : XBaseInMemoryRepository<TEntity, TKey>
|
||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
{
|
||||
//
|
||||
@@ -513,6 +514,144 @@ namespace xDataService.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 AddXRepository<
|
||||
TEntity,
|
||||
TKey,
|
||||
TKeyGeneratorService,
|
||||
TKeyGeneratorImplementation,
|
||||
TEventsService,
|
||||
TEventsImplementation,
|
||||
TGraph,
|
||||
TGraphKey,
|
||||
TGraphQuery,
|
||||
TGraphTypeHelperService,
|
||||
TGraphTypeHelperImplementation,
|
||||
TGraphSchema,
|
||||
TRepositoryService,
|
||||
TRepositoryImplementation,
|
||||
TSeederService,
|
||||
TSeederImplementation
|
||||
>(
|
||||
IServiceCollection source,
|
||||
XInMemoryRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TSeederService, TSeederImplementation> repositoryDescriptor,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Scoped
|
||||
)
|
||||
where TGraphSchema : Schema
|
||||
where TGraphKey : IGraphType
|
||||
where TEntity : XBaseEntity<TKey>
|
||||
where TSeederService : IXBaseDbSeeder<TEntity, TKey>
|
||||
where TSeederImplementation : XBaseDbSeeder<TEntity, 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 : XBaseInMemoryRepository<TEntity, TKey>
|
||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
{
|
||||
//
|
||||
var isValid = repositoryDescriptor.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Register KeyGenerator ...
|
||||
isValid = repositoryDescriptor.HasKeyGenerator();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXKeyGenerator<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Events ...
|
||||
isValid = repositoryDescriptor.HasEvents();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXEvents<TEntity, TKey, TEventsService, TEventsImplementation>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Graph ...
|
||||
isValid = repositoryDescriptor.HasGraphSupport();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Repository ...
|
||||
isValid = repositoryDescriptor.HasRepository();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
repositoryDescriptor.RepositoryService,
|
||||
repositoryDescriptor.RepositoryImplementation,
|
||||
lifetime
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// DbSeeder ...
|
||||
isValid = repositoryDescriptor.HasSeeder();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
repositoryDescriptor.SeederService,
|
||||
repositoryDescriptor.SeederImplementation,
|
||||
lifetime
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Repository ...
|
||||
/// </summary>
|
||||
@@ -630,6 +769,144 @@ namespace xDataService.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 AddXRepository<
|
||||
TEntity,
|
||||
TKey,
|
||||
TKeyGeneratorService,
|
||||
TKeyGeneratorImplementation,
|
||||
TEventsService,
|
||||
TEventsImplementation,
|
||||
TGraph,
|
||||
TGraphKey,
|
||||
TGraphQuery,
|
||||
TGraphTypeHelperService,
|
||||
TGraphTypeHelperImplementation,
|
||||
TGraphSchema,
|
||||
TRepositoryService,
|
||||
TRepositoryImplementation,
|
||||
TSeederService,
|
||||
TSeederImplementation
|
||||
>(
|
||||
IServiceCollection source,
|
||||
XMongoRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TSeederService, TSeederImplementation> repositoryDescriptor,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Scoped
|
||||
)
|
||||
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 TKeyGeneratorService : IXKeyGenerator<TEntity, TKey>
|
||||
where TRepositoryService : IXBaseRepository<TEntity, TKey>
|
||||
where TSeederImplementation : XBaseDbSeeder<TEntity, TKey>
|
||||
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
||||
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
||||
where TRepositoryImplementation : XBaseMongoRepository<TEntity, TKey>
|
||||
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
{
|
||||
//
|
||||
var isValid = repositoryDescriptor.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Register KeyGenerator ...
|
||||
isValid = repositoryDescriptor.HasKeyGenerator();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXKeyGenerator<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Events ...
|
||||
isValid = repositoryDescriptor.HasEvents();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXEvents<TEntity, TKey, TEventsService, TEventsImplementation>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Graph ...
|
||||
isValid = repositoryDescriptor.HasGraphSupport();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Repository ...
|
||||
isValid = repositoryDescriptor.HasRepository();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
repositoryDescriptor.RepositoryService,
|
||||
repositoryDescriptor.RepositoryImplementation,
|
||||
lifetime
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// DbSeeder ...
|
||||
isValid = repositoryDescriptor.HasSeeder();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
repositoryDescriptor.SeederService,
|
||||
repositoryDescriptor.SeederImplementation,
|
||||
lifetime
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Repository ...
|
||||
/// </summary>
|
||||
@@ -750,6 +1027,147 @@ namespace xDataService.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
/// <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="TContext"></typeparam>
|
||||
/// <typeparam name="TSeederService"></typeparam>
|
||||
/// <typeparam name="TSeederImplementation"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static void AddXRepository<
|
||||
TEntity,
|
||||
TKey,
|
||||
TKeyGeneratorService,
|
||||
TKeyGeneratorImplementation,
|
||||
TEventsService,
|
||||
TEventsImplementation,
|
||||
TGraph,
|
||||
TGraphKey,
|
||||
TGraphQuery,
|
||||
TGraphTypeHelperService,
|
||||
TGraphTypeHelperImplementation,
|
||||
TGraphSchema,
|
||||
TRepositoryService,
|
||||
TRepositoryImplementation,
|
||||
TContext,
|
||||
TSeederService,
|
||||
TSeederImplementation
|
||||
>(
|
||||
IServiceCollection source,
|
||||
XEFRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TContext, TSeederService, TSeederImplementation> repositoryDescriptor,
|
||||
ServiceLifetime lifetime = ServiceLifetime.Scoped
|
||||
)
|
||||
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>
|
||||
{
|
||||
//
|
||||
var isValid = repositoryDescriptor.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Register KeyGenerator ...
|
||||
isValid = repositoryDescriptor.HasKeyGenerator();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXKeyGenerator<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Events ...
|
||||
isValid = repositoryDescriptor.HasEvents();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXEvents<TEntity, TKey, TEventsService, TEventsImplementation>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Graph ...
|
||||
isValid = repositoryDescriptor.HasGraphSupport();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||
source,
|
||||
repositoryDescriptor,
|
||||
lifetime
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Register Repository ...
|
||||
isValid = repositoryDescriptor.HasRepository();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
repositoryDescriptor.RepositoryService,
|
||||
repositoryDescriptor.RepositoryImplementation,
|
||||
lifetime
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// DbSeeder ...
|
||||
isValid = repositoryDescriptor.HasSeeder();
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
repositoryDescriptor.SeederService,
|
||||
repositoryDescriptor.SeederImplementation,
|
||||
lifetime
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Repository ...
|
||||
/// </summary>
|
||||
@@ -800,7 +1218,7 @@ namespace xDataService.Helpers
|
||||
where TEventsImplementation : XBaseRepositoryEvents<TEntity>
|
||||
where TKeyGeneratorImplementation : XKeyGenerator<TEntity, TKey>
|
||||
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
where TRepositoryImplementation : XBaseInMemoryRepositoy<TEntity, TKey>
|
||||
where TRepositoryImplementation : XBaseInMemoryRepository<TEntity, TKey>
|
||||
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
{
|
||||
@@ -898,79 +1316,113 @@ namespace xDataService.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Repository ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="repositoryDescriptor"></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="TContext"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static void UseXRepository<
|
||||
// /// <summary>
|
||||
// /// Register Repository ...
|
||||
// /// </summary>
|
||||
// /// <param name="source"></param>
|
||||
// /// <param name="repositoryDescriptor"></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="TContext"></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>
|
||||
// {
|
||||
// //
|
||||
// var isValid = repositoryDescriptor.IsValid();
|
||||
// if (!isValid)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// //
|
||||
// // GraphQL ...
|
||||
// isValid = repositoryDescriptor.HasGraphSupport();
|
||||
// if (isValid)
|
||||
// {
|
||||
// //
|
||||
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||
// source,
|
||||
// repositoryDescriptor
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void UseXGraphQL<
|
||||
TEntity,
|
||||
TKey,
|
||||
TKeyGeneratorService,
|
||||
TKeyGeneratorImplementation,
|
||||
TEventsService,
|
||||
TEventsImplementation,
|
||||
TGraph,
|
||||
TGraphKey,
|
||||
TGraphQuery,
|
||||
TGraphTypeHelperService,
|
||||
TGraphTypeHelperImplementation,
|
||||
TGraphSchema,
|
||||
TRepositoryService,
|
||||
TRepositoryImplementation,
|
||||
TContext
|
||||
TGraphSchema
|
||||
>(
|
||||
IApplicationBuilder source,
|
||||
XEFRepositoryDescriptor<TEntity, TKey, TKeyGeneratorService, TKeyGeneratorImplementation, TEventsService, TEventsImplementation, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema, TRepositoryService, TRepositoryImplementation, TContext> repositoryDescriptor
|
||||
string graphPath,
|
||||
bool withPlayGround = false,
|
||||
GraphQLPlaygroundOptions options = null
|
||||
)
|
||||
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>
|
||||
{
|
||||
//
|
||||
var isValid = repositoryDescriptor.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
source.UseGraphQL<TGraphSchema>(graphPath);
|
||||
source.UseGraphQLWebSockets<TGraphSchema>();
|
||||
|
||||
//
|
||||
// GraphQL ...
|
||||
isValid = repositoryDescriptor.HasGraphSupport();
|
||||
if (isValid)
|
||||
if (withPlayGround)
|
||||
{
|
||||
//
|
||||
UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||
source,
|
||||
repositoryDescriptor
|
||||
);
|
||||
source.UseGraphQLPlayground(options);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user