public static IQueryExecutionBuilder AddErrorFilter <T>( this IQueryExecutionBuilder builder) where T : class, IErrorFilter { builder.Services.AddSingleton <IErrorFilter, T>(); return(builder); }
public static IQueryExecutionBuilder UseInstrumentation( this IQueryExecutionBuilder builder, TracingPreference tracingPreference) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var listener = new DiagnosticListener(DiagnosticNames.Listener); builder .RemoveService <DiagnosticListener>() .RemoveService <DiagnosticSource>(); builder.Services .AddSingleton(listener) .AddSingleton <DiagnosticSource>(listener) .AddSingleton(sp => new QueryExecutionDiagnostics( sp.GetRequiredService <DiagnosticListener>(), sp.GetServices <IDiagnosticObserver>())); if (tracingPreference != TracingPreference.Never) { builder .AddDiagnosticObserver(new ApolloTracingDiagnosticObserver( tracingPreference)); } return(builder.Use <InstrumentationMiddleware>()); }
public static IQueryExecutionBuilder MapField( this IQueryExecutionBuilder builder, FieldReference fieldReference, FieldMiddleware middleware) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (fieldReference == null) { throw new ArgumentNullException(nameof(fieldReference)); } if (middleware == null) { throw new ArgumentNullException(nameof(middleware)); } return(builder.UseField( FieldClassMiddlewareFactory.Create <MapMiddleware>( (s, n) => new MapMiddleware( n, fieldReference, middleware(n))))); }
public static IQueryExecutionBuilder AddDefaultValidationRules( this IQueryExecutionBuilder builder) { builder.Services.AddDefaultValidationRules(); return(builder); }
public static IQueryExecutionBuilder AddOptions( this IQueryExecutionBuilder builder, IQueryExecutionOptionsAccessor options) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } builder .RemoveService <IQueryExecutionOptionsAccessor>() .RemoveService <IErrorHandlerOptionsAccessor>() .RemoveService <IInstrumentationOptionsAccessor>() .RemoveService <IQueryCacheSizeOptionsAccessor>() .RemoveService <IRequestTimeoutOptionsAccessor>() .RemoveService <IValidateQueryOptionsAccessor>(); builder.Services.AddOptions(options); return(builder); }
public static IQueryExecutionBuilder UseQueryDelegationPipeline( this IQueryExecutionBuilder builder, IQueryExecutionOptionsAccessor options, string schemaName) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (string.IsNullOrEmpty(schemaName)) { throw new ArgumentException( "The schema name mustn't be null or empty.", nameof(schemaName)); } return(builder .AddOptions(options) .AddErrorHandler() .AddDefaultParser() .UseRequestTimeout() .UseExceptionHandling() .UseRemoteQueryExecutor(schemaName)); }
public static IQueryExecutionBuilder UseStitchingPipeline( this IQueryExecutionBuilder builder) { return(UseStitchingPipeline( builder, new QueryExecutionOptions())); }
public static IQueryExecutionBuilder UseInstrumentation( this IQueryExecutionBuilder builder, IInstrumentationOptionsAccessor options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } builder.Services .AddSingleton(options) .AddScoped <DiagnosticListenerInitializer>(); if (options.EnableTracing) { builder.Services .AddScoped < IApolloTracingResultBuilder, ApolloTracingResultBuilder>() .AddScoped < DiagnosticListener, ApolloTracingDiagnosticListener>(); } return(builder.Use <InstrumentationMiddleware>()); }
public static IQueryExecutionBuilder UseDefaultPipeline( this IQueryExecutionBuilder builder, IQueryExecutionOptionsAccessor options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } return(builder .AddErrorHandler(options) .AddQueryValidation(options) .AddDefaultValidationRules() .AddQueryCache(options) .AddExecutionStrategyResolver() .AddDefaultParser() .UseInstrumentation(options) .UseRequestTimeout(options) .UseExceptionHandling() .UseQueryParser() .UseValidation() .UseOperationResolver() .UseCoerceVariables() .UseOperationExecuter()); }
public static IQueryExecutionBuilder UseStitchingPipeline( this IQueryExecutionBuilder builder, IQueryExecutionOptionsAccessor options) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return(builder .AddDefaultServices(options) .UseDefaultDiagnostics(options) .UseQueryParser() .UseNoCachedQueryError() .UseValidation() .UseOperationResolver() .UseMaxComplexity() .UsePropagateVariables() .UseOperationExecutor()); }
public static IQueryExecutionBuilder MapField <TMiddleware>( this IQueryExecutionBuilder builder, FieldReference fieldReference, Func <IServiceProvider, FieldDelegate, TMiddleware> factory) where TMiddleware : class { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (fieldReference == null) { throw new ArgumentNullException(nameof(fieldReference)); } if (factory == null) { throw new ArgumentNullException(nameof(factory)); } return(builder.UseField( FieldClassMiddlewareFactory.Create <MapMiddleware>( (s, n) => { FieldMiddleware classMiddleware = FieldClassMiddlewareFactory.Create(factory); return new MapMiddleware( n, fieldReference, classMiddleware(n)); }))); }
public static IQueryExecutionBuilder UseDefaultPipeline( this IQueryExecutionBuilder builder, IQueryExecutionOptionsAccessor options) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return(builder .AddOptions(options) .AddErrorHandler() .AddQueryValidation() .AddDefaultValidationRules() .AddQueryCache(options.QueryCacheSize) .AddExecutionStrategyResolver() .AddDefaultParser() .UseInstrumentation(options.TracingPreference) .UseRequestTimeout() .UseExceptionHandling() .UseQueryParser() .UseValidation() .UseOperationResolver() .UseMaxComplexity() .UseOperationExecutor()); }
public static IQueryExecutionBuilder UseField <TMiddleware>( this IQueryExecutionBuilder builder, Func <IServiceProvider, FieldDelegate, TMiddleware> factory) where TMiddleware : class { return(builder.UseField( FieldClassMiddlewareFactory.Create <TMiddleware>(factory))); }
public static IQueryExecutionBuilder AddValidationRule( this IQueryExecutionBuilder builder, Func <IServiceProvider, IQueryValidationRule> factory) { builder.Services.AddSingleton(factory); return(builder); }
public static IQueryExecutionBuilder AddQueryValidation( this IQueryExecutionBuilder builder, IValidateQueryOptionsAccessor options) { builder.Services.AddQueryValidation(options); return(builder); }
public static IQueryExecutionBuilder AddValidationRule <T>( this IQueryExecutionBuilder builder) where T : class, IQueryValidationRule { builder.Services.AddSingleton <IQueryValidationRule, T>(); return(builder); }
private static IQueryExecutionBuilder UseDefaultDiagnostics( this IQueryExecutionBuilder builder, IInstrumentationOptionsAccessor options) { return(builder .UseInstrumentation(options.TracingPreference) .UseRequestTimeout() .UseExceptionHandling()); }
public static IQueryExecutionBuilder UseQueryDelegationPipeline( this IQueryExecutionBuilder builder, string schemaName) { return(UseQueryDelegationPipeline( builder, new QueryExecutionOptions(), schemaName)); }
public static IQueryExecutionBuilder AddMD5DocumentHashProvider( this IQueryExecutionBuilder builder, HashFormat format) { builder.RemoveService <IDocumentHashProvider>(); builder.Services.AddSingleton <IDocumentHashProvider>( new MD5DocumentHashProvider(format)); return(builder); }
public static IQueryExecutionBuilder AddParser <T>( this IQueryExecutionBuilder builder) where T : class, IQueryParser { builder.RemoveService <IQueryParser>(); builder.Services.AddSingleton <IQueryParser, T>(); return(builder); }
public static IQueryExecutionBuilder AddSha256DocumentHashProvider( this IQueryExecutionBuilder builder) { builder.RemoveService <IDocumentHashProvider>(); builder.Services.AddSingleton < IDocumentHashProvider, Sha256DocumentHashProvider>(); return(builder); }
public static IQueryExecutor MakeExecutable( this ISchema schema, Func <IQueryExecutionBuilder, IQueryExecutionBuilder> configure) { IQueryExecutionBuilder builder = configure( QueryExecutionBuilder.New()); return(builder.Build(schema)); }
public static IQueryExecutionBuilder AddExecutionStrategyResolver( this IQueryExecutionBuilder builder) { builder.RemoveService <IExecutionStrategyResolver>(); builder.Services.AddSingleton < IExecutionStrategyResolver, ExecutionStrategyResolver>(); return(builder); }
private static IQueryExecutionBuilder RemoveService <TService>( this IQueryExecutionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.RemoveService(typeof(TService))); }
public static IQueryExecutionBuilder UseExceptionHandling( this IQueryExecutionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.Use <ExceptionMiddleware>()); }
public static IQueryExecutionBuilder AddDefaultParser( this IQueryExecutionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(AddParser <DefaultQueryParser>(builder)); }
public static IQueryExecutionBuilder UseMaxComplexity( this IQueryExecutionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.Use <MaxComplexityMiddleware>()); }
public static IQueryExecutionBuilder UseValidation( this IQueryExecutionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.Use <ValidateQueryMiddleware>()); }
public static IQueryExecutionBuilder UseRequestTimeout( this IQueryExecutionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.Use <RequestTimeoutMiddleware>()); }
public static IQueryExecutionBuilder UseOperationResolver( this IQueryExecutionBuilder builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.Use <ResolveOperationMiddleware>()); }