Fix GraphQL Implementation and also UI Playground and add supports for Oracle Provider using EF Core ...
This commit is contained in:
+461
-185
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using GraphQL;
|
||||
using GraphQL.Server;
|
||||
using GraphQL.Server.Ui.Playground;
|
||||
using GraphQL.Types;
|
||||
@@ -83,6 +84,21 @@ namespace xDataService.Helpers
|
||||
}, lifetime);
|
||||
break;
|
||||
|
||||
//
|
||||
// Oracle ...
|
||||
case XDbProviders.Oracle:
|
||||
//
|
||||
source.AddEntityFrameworkOracle();
|
||||
source.AddDbContext<TContext>(cfg =>
|
||||
{
|
||||
//
|
||||
cfg.UseOracle(
|
||||
databaseDescriptor.ConnectionString,
|
||||
databaseDescriptor.OptionsBuilder
|
||||
);
|
||||
}, lifetime);
|
||||
break;
|
||||
|
||||
//
|
||||
// SQLServer ...
|
||||
case XDbProviders.SQLServer:
|
||||
@@ -153,6 +169,7 @@ namespace xDataService.Helpers
|
||||
isValid =
|
||||
databaseDescriptor.Provider == XDbProviders.MySQL ||
|
||||
databaseDescriptor.Provider == XDbProviders.SQLite ||
|
||||
databaseDescriptor.Provider == XDbProviders.Oracle ||
|
||||
databaseDescriptor.Provider == XDbProviders.SQLServer;
|
||||
if (isValid)
|
||||
{
|
||||
@@ -1223,22 +1240,118 @@ namespace xDataService.Helpers
|
||||
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
|
||||
);
|
||||
// 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,
|
||||
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>
|
||||
{
|
||||
//
|
||||
// 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
|
||||
);
|
||||
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||
// source,
|
||||
// repositoryDescriptor
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
// /// <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;
|
||||
// }
|
||||
/// <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,
|
||||
XMongoRepositoryDescriptor<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 TRepositoryImplementation : XBaseMongoRepository<TEntity, TKey>
|
||||
where TGraphTypeHelperService : IXBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
where TGraphQuery : XBaseGraphQLQuery<TEntity, TKey, TGraph, TGraphKey>
|
||||
where TGraphTypeHelperImplementation : XBaseGraphQLTypeHelper<TEntity, TKey>
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
var isValid = repositoryDescriptor.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// //
|
||||
// // GraphQL ...
|
||||
// isValid = repositoryDescriptor.HasGraphSupport();
|
||||
// if (isValid)
|
||||
// {
|
||||
// //
|
||||
// UseXGraphQL<TEntity, TKey, TGraph, TGraphKey, TGraphQuery, TGraphTypeHelperService, TGraphTypeHelperImplementation, TGraphSchema>(
|
||||
// source,
|
||||
// repositoryDescriptor
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// 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>
|
||||
/// <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<
|
||||
TEntity,
|
||||
TKey,
|
||||
@@ -1422,6 +1745,14 @@ namespace xDataService.Helpers
|
||||
//
|
||||
if (withPlayGround)
|
||||
{
|
||||
//
|
||||
if (options.IsNull())
|
||||
{
|
||||
options = new GraphQLPlaygroundOptions();
|
||||
}
|
||||
options.Path = "/ui/playground";
|
||||
|
||||
//
|
||||
source.UseGraphQLPlayground(options);
|
||||
}
|
||||
}
|
||||
@@ -1600,43 +1931,13 @@ namespace xDataService.Helpers
|
||||
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 ...
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
repositoryDescriptor.GraphType,
|
||||
repositoryDescriptor.GraphType,
|
||||
ServiceLifetime.Singleton
|
||||
lifetime: ServiceLifetime.Singleton,
|
||||
serviceType: repositoryDescriptor.GraphType,
|
||||
implementationType: repositoryDescriptor.GraphType
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1644,19 +1945,60 @@ namespace xDataService.Helpers
|
||||
// Register Graph Events ...
|
||||
source.Add(
|
||||
new ServiceDescriptor(
|
||||
typeof(XBaseGraphQLEventType<TEntity, TKey, TGraph>),
|
||||
typeof(XBaseGraphQLEventType<TEntity, TKey, TGraph>),
|
||||
ServiceLifetime.Singleton
|
||||
lifetime: ServiceLifetime.Singleton,
|
||||
serviceType: typeof(XBaseGraphQLEventType<TEntity, TKey, TGraph>),
|
||||
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 ...
|
||||
var builder = source.GetRegisteredService<IGraphQLBuilder>();
|
||||
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)
|
||||
.AddNewtonsoftJson(deserializerSettings => { }, serializerSettings => { })
|
||||
.AddWebSockets()
|
||||
@@ -1665,72 +2007,6 @@ namespace xDataService.Helpers
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user