elsa-core/src/server/Elsa.Server.GraphQL/Extensions/GraphQLServiceCollectionExtensions.cs

33 lines
879 B
C#
Raw Normal View History

2019-11-22 22:07:31 +00:00
using System;
using Elsa;
using Elsa.AutoMapper.Extensions;
using Elsa.Mapping;
using Elsa.Serialization;
using Elsa.Serialization.Formatters;
using Elsa.Server.GraphQL;
using Elsa.Services;
using GraphQL.Server;
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>()
.AddLogging();
var graphQLOptions = new GraphQLOptions();
configure?.Invoke(graphQLOptions);
services
.AddGraphQL(graphQLOptions)
.AddGraphTypes(ServiceLifetime.Scoped);
return builder;
}
}
}