2019-11-22 22:07:31 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using Elsa;
|
|
|
|
|
|
using Elsa.AutoMapper.Extensions;
|
|
|
|
|
|
using Elsa.Server.GraphQL;
|
2019-11-23 14:08:40 +00:00
|
|
|
|
using Elsa.Server.GraphQL.Mapping;
|
2019-11-22 22:07:31 +00:00
|
|
|
|
using GraphQL.Server;
|
|
|
|
|
|
|
2019-11-23 14:08:40 +00:00
|
|
|
|
// ReSharper disable once CheckNamespace
|
2019-11-22 22:07:31 +00:00
|
|
|
|
namespace Microsoft.Extensions.DependencyInjection
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class GraphQLServiceCollectionExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
public static ElsaBuilder AddGraphQL(this ElsaBuilder builder, Action<GraphQLOptions> configure = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var services = builder.Services;
|
|
|
|
|
|
|
|
|
|
|
|
services
|
|
|
|
|
|
.AddScoped<ElsaSchema>()
|
2019-11-23 14:08:40 +00:00
|
|
|
|
.AddAutoMapperProfile<GraphQLProfile>(ServiceLifetime.Singleton)
|
2019-11-22 22:07:31 +00:00
|
|
|
|
.AddLogging();
|
|
|
|
|
|
|
|
|
|
|
|
var graphQLOptions = new GraphQLOptions();
|
|
|
|
|
|
configure?.Invoke(graphQLOptions);
|
|
|
|
|
|
|
|
|
|
|
|
services
|
|
|
|
|
|
.AddGraphQL(graphQLOptions)
|
|
|
|
|
|
.AddGraphTypes(ServiceLifetime.Scoped);
|
|
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|