/// <summary> /// Add GraphQL services to the specified <see cref="IServiceCollection">IServiceCollection</see>. /// </summary> /// <param name="services"></param> /// <param name="configure">Action to configure the default schema.</param> /// <returns></returns> public static IGraphQlBuilder AddGraphQl(this IServiceCollection services, Action <SchemaConfiguration> configure) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (configure == null) { throw new ArgumentNullException(nameof(configure)); } // commented out because of https://github.com/graphql-dotnet/graphql-dotnet/issues/478 // to use it, uncomment the line in Program.cs // services.AddScoped<DocumentExecuter>(); services.AddSingleton <DocumentExecuter>(); var builder = new GraphQlBuilder(services); var schema = new SchemaConfiguration(null); configure(schema); return(builder.AddSchema(schema)); }
/// <summary> /// Add GraphQL services to the specified <see cref="IServiceCollection">IServiceCollection</see>. /// </summary> /// <param name="services"></param> /// <param name="configure">Action to configure the default schema.</param> /// <returns></returns> public static IGraphQlBuilder AddGraphQl(this IServiceCollection services, Action <SchemaConfiguration> configure) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var builder = new GraphQlBuilder(services); var schema = new SchemaConfiguration(null); configure(schema); return(builder.AddSchema(schema)); }