public HttpPostMiddleware( RequestDelegate next, IHttpPostMiddlewareOptions options, IQueryExecutor queryExecutor, IBatchQueryExecutor batchQueryExecutor, IQueryResultSerializer resultSerializer, IResponseStreamSerializer streamSerializer, IDocumentCache documentCache, IDocumentHashProvider documentHashProvider, IErrorHandler errorHandler) : base(next, options, resultSerializer, errorHandler) { _queryExecutor = queryExecutor ?? throw new ArgumentNullException(nameof(queryExecutor)); _batchExecutor = batchQueryExecutor ?? throw new ArgumentNullException(nameof(batchQueryExecutor)); _resultSerializer = resultSerializer ?? throw new ArgumentNullException(nameof(resultSerializer)); _streamSerializer = streamSerializer ?? throw new ArgumentNullException(nameof(streamSerializer)); _requestHelper = new RequestHelper( documentCache, documentHashProvider, options.MaxRequestSize, options.ParserOptions); }
/// <summary> /// Initializes a new instance with specified <see cref="IDocumentBuilder"/>, /// <see cref="IDocumentValidator"/>, <see cref="IComplexityAnalyzer"/>, /// and <see cref="IDocumentCache"/> instances. /// </summary> public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache) { _documentBuilder = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder)); _documentValidator = documentValidator ?? throw new ArgumentNullException(nameof(documentValidator)); _complexityAnalyzer = complexityAnalyzer ?? throw new ArgumentNullException(nameof(complexityAnalyzer)); _documentCache = documentCache ?? throw new ArgumentNullException(nameof(documentCache)); }
public Utf8GraphQLRequestParser(ReadOnlySpan <byte> requestData) { _options = ParserOptions.Default; _reader = new Utf8GraphQLReader(requestData); _cache = null; _hashProvider = null; _useCache = false; }
/// <summary> /// Initializes a new instance with the specified <see cref="IDocumentBuilder"/>, /// <see cref="IDocumentValidator"/>, <see cref="IComplexityAnalyzer"/>, /// <see cref="IDocumentCache"/> and a set of <see cref="IConfigureExecutionOptions"/> instances. /// </summary> public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IEnumerable <IConfigureExecutionOptions> configurations, IExecutionStrategySelector executionStrategySelector) { _documentBuilder = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder)); _documentValidator = documentValidator ?? throw new ArgumentNullException(nameof(documentValidator)); _complexityAnalyzer = complexityAnalyzer ?? throw new ArgumentNullException(nameof(complexityAnalyzer)); _documentCache = documentCache ?? throw new ArgumentNullException(nameof(documentCache)); _configurations = configurations?.ToArray(); _executionStrategySelector = executionStrategySelector ?? throw new ArgumentNullException(nameof(executionStrategySelector)); }
/// <summary> /// Initializes a new instance with the specified <see cref="IDocumentBuilder"/>, /// <see cref="IDocumentValidator"/>, <see cref="IComplexityAnalyzer"/>, /// <see cref="IDocumentCache"/> and a set of <see cref="IConfigureExecutionOptions"/> instances. /// </summary> private DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IExecutionStrategySelector executionStrategySelector, IEnumerable <IConfigureExecution> configurations) { // TODO: in v6 make this public _documentBuilder = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder)); _documentValidator = documentValidator ?? throw new ArgumentNullException(nameof(documentValidator)); _complexityAnalyzer = complexityAnalyzer ?? throw new ArgumentNullException(nameof(complexityAnalyzer)); _documentCache = documentCache ?? throw new ArgumentNullException(nameof(documentCache)); _executionStrategySelector = executionStrategySelector ?? throw new ArgumentNullException(nameof(executionStrategySelector)); _execution = BuildExecutionDelegate(configurations); }
public ApolloTracingDocumentExecuter( IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IEnumerable <IConfigureExecutionOptions> configureExecutionOptions, IExecutionStrategySelector executionStrategySelector) : base(documentBuilder, documentValidator, complexityAnalyzer, documentCache, configureExecutionOptions, executionStrategySelector) { }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="catalog"></param> /// <param name="exports"></param> /// <param name="store"></param> /// <param name="cache"></param> ViewServer( ComposablePartCatalog catalog = null, ExportProvider exports = null, IDocumentStore store = null, IDocumentCache cache = null) { this.catalog = catalog; this.exports = exports; this.store = store ?? new DefaultDocumentStore(); this.cache = cache ?? new DefaultDocumentCache(); }
public MirrorIntegrationCoordinatorService(IIntegrationService[] integrationServices, IDocumentPipeline documentPipeline, IDocumentCache documentCache) { _integrationServices = integrationServices; _documentPipeline = documentPipeline; _documentCache = documentCache; if (!_integrationServices.Any()) { Log.Warning("No integration services enabled (app.config). No dispatch will take place."); } }
public Utf8GraphQLRequestParser( ReadOnlySpan <byte> requestData, ParserOptions options, IDocumentCache cache, IDocumentHashProvider hashProvider) { _options = options ?? throw new ArgumentNullException(nameof(options)); _cache = cache; _hashProvider = hashProvider; _reader = new Utf8GraphQLReader(requestData); _useCache = cache != null; }
public Utf8GraphQLRequestParser( ReadOnlySpan <byte> requestData, ParserOptions options) { _options = options ?? throw new ArgumentNullException(nameof(options)); _reader = new Utf8GraphQLReader(requestData); _cache = null; _hashProvider = null; _useCache = false; }
public DocumentCacheMiddleware( RequestDelegate next, IDiagnosticEvents diagnosticEvents, IDocumentCache documentCache, IDocumentHashProvider documentHashProvider) { _next = next ?? throw new ArgumentNullException(nameof(next)); _diagnosticEvents = diagnosticEvents ?? throw new ArgumentNullException(nameof(diagnosticEvents)); _documentCache = documentCache ?? throw new ArgumentNullException(nameof(documentCache)); _documentHashProvider = documentHashProvider ?? throw new ArgumentNullException(nameof(documentHashProvider)); }
public PostQueryMiddleware( RequestDelegate next, IQueryExecutor queryExecutor, IQueryResultSerializer resultSerializer, IDocumentCache documentCache, IDocumentHashProvider documentHashProvider, QueryMiddlewareOptions options) : base(next, queryExecutor, resultSerializer, options) { _requestHelper = new RequestHelper( documentCache, documentHashProvider, options.MaxRequestSize, options.ParserOptions); }
public GraphQLFunctions(IQueryExecutor executor, IDocumentCache documentCache, IDocumentHashProvider documentHashProvider, IAzureFunctionsMiddlewareOptions azureFunctionsOptions /*JsonQueryResultSerializer jsonQueryResultSerializer*/) { Executor = executor; DocumentCache = documentCache; DocumentHashProvider = documentHashProvider; AzureFunctionsOptions = azureFunctionsOptions; _jsonQueryResultSerializer = new JsonQueryResultSerializer(); _requestParser = new RequestHelper( DocumentCache, DocumentHashProvider, AzureFunctionsOptions.MaxRequestSize, AzureFunctionsOptions.ParserOptions); }
public RequestHelper( IDocumentCache documentCache, IDocumentHashProvider documentHashProvider, int maxRequestSize, ParserOptions parserOptions) { _documentCache = documentCache ?? throw new ArgumentNullException(nameof(documentCache)); _documentHashProvider = documentHashProvider ?? throw new ArgumentNullException(nameof(documentHashProvider)); _maxRequestSize = maxRequestSize < _minRequestSize ? _minRequestSize : maxRequestSize; _parserOptions = parserOptions ?? throw new ArgumentNullException(nameof(parserOptions)); }
public static IApplicationBuilder UseGraphQLHttpPost( this IApplicationBuilder applicationBuilder, IServiceProvider serviceProvider, IHttpPostMiddlewareOptions options) { if (applicationBuilder == null) { throw new ArgumentNullException(nameof(applicationBuilder)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } IQueryExecutor executor = serviceProvider .GetRequiredService <IQueryExecutor>(); IBatchQueryExecutor batchQueryExecutor = serviceProvider .GetRequiredService <IBatchQueryExecutor>(); IQueryResultSerializer resultSerializer = serviceProvider .GetRequiredService <IQueryResultSerializer>(); IResponseStreamSerializer streamSerializer = serviceProvider .GetRequiredService <IResponseStreamSerializer>(); IDocumentCache documentCache = serviceProvider .GetRequiredService <IDocumentCache>(); IDocumentHashProvider documentHashProvider = serviceProvider .GetRequiredService <IDocumentHashProvider>(); OwinContextAccessor contextAccessor = serviceProvider.GetService <OwinContextAccessor>(); return(applicationBuilder.Use <HttpPostMiddleware>( options, contextAccessor, executor, batchQueryExecutor, resultSerializer, streamSerializer, documentCache, documentHashProvider)); }
public static IApplicationBuilder UseGraphQL( this IApplicationBuilder applicationBuilder, IServiceProvider serviceProvider, QueryMiddlewareOptions options) { if (applicationBuilder == null) { throw new ArgumentNullException(nameof(applicationBuilder)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } IQueryExecutor executor = serviceProvider .GetService <IQueryExecutor>(); IQueryResultSerializer serializer = serviceProvider .GetService <IQueryResultSerializer>() ?? new JsonQueryResultSerializer(); IDocumentCache cache = serviceProvider .GetRequiredService <IDocumentCache>(); IDocumentHashProvider hashProvider = serviceProvider .GetRequiredService <IDocumentHashProvider>(); return(applicationBuilder .Use <PostQueryMiddleware>(executor, serializer, cache, hashProvider, options) .Use <GetQueryMiddleware>(executor, serializer, options) .Use <SchemaMiddleware>(executor, options)); }
public static IDocumentDb WithCaching(this IDocumentDb db, IDocumentCache cache = null) { return(new DocumentDbWithCaching(cache ?? new InMemoryCache(), db)); }
/// <summary> /// Initializes a new instance with specified <see cref="IDocumentBuilder"/>, /// <see cref="IDocumentValidator"/>, <see cref="IComplexityAnalyzer"/>, /// and <see cref="IDocumentCache"/> instances. /// </summary> public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache) : this(documentBuilder, documentValidator, complexityAnalyzer, documentCache, null !) { }
/// <summary> /// Initializes a new instance with specified <see cref="IDocumentBuilder"/>, /// <see cref="IDocumentValidator"/>, <see cref="IComplexityAnalyzer"/>, /// <see cref="IDocumentCache"/> and a set of <see cref="IConfigureExecutionOptions"/> instances. /// </summary> public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IEnumerable <IConfigureExecutionOptions> configurations) : this(documentBuilder, documentValidator, complexityAnalyzer, documentCache, configurations, new DefaultExecutionStrategySelector()) { }
public GraphHttpRequestHandler(IServiceProvider serviceProvider, IQueryExecutor queryExecutor, IDocumentCache documentCache, IDocumentHashProvider documentHashProvider, IGraphHttpRequestHandlerOptions graphHttpRequestHanlderOptions) : base(documentCache, documentHashProvider, graphHttpRequestHanlderOptions.MaxRequestSize, graphHttpRequestHanlderOptions.ParserOptions) { Executor = queryExecutor; ServiceProvider = serviceProvider; }
public SubscriptionDocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache) : base(documentBuilder, documentValidator, complexityAnalyzer, documentCache) { }
/// <summary> /// Initializes a new instance with the specified <see cref="IDocumentBuilder"/>, /// <see cref="IDocumentValidator"/>, <see cref="IComplexityAnalyzer"/>, /// <see cref="IDocumentCache"/> and a set of <see cref="IConfigureExecutionOptions"/> instances. /// </summary> public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IExecutionStrategySelector executionStrategySelector, IEnumerable <IConfigureExecution> configurations, IEnumerable <IConfigureExecutionOptions> optionsConfigurations) #pragma warning disable CS0618 // Type or member is obsolete : this(documentBuilder, documentValidator, complexityAnalyzer, documentCache, executionStrategySelector, configurations.Append(new ConfigureExecutionOptionsMapper(optionsConfigurations))) #pragma warning restore CS0618 // Type or member is obsolete { // TODO: remove in v6 }
public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IEnumerable <IConfigureExecutionOptions> configurations, IExecutionStrategySelector executionStrategySelector) : this(documentBuilder, documentValidator, complexityAnalyzer, documentCache, executionStrategySelector, new IConfigureExecution[] { new ConfigureExecutionOptionsMapper(configurations) }) { }
/// <summary> /// Initializes a new instance with specified <see cref="IDocumentBuilder"/>, /// <see cref="IDocumentValidator"/>, <see cref="IComplexityAnalyzer"/>, /// and <see cref="IDocumentCache"/> instances. /// </summary> public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache) : this(documentBuilder, documentValidator, complexityAnalyzer, documentCache, new DefaultExecutionStrategySelector(), Array.Empty <IConfigureExecution>()) { }
public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IEnumerable <IConfigureExecution>?configurations) : this(documentBuilder, documentValidator, complexityAnalyzer, documentCache) { _configurations = configurations; }
public SubscriptionDocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, IDocumentCache documentCache, IEnumerable <IConfigureExecution>?configurations) : base(documentBuilder, documentValidator, complexityAnalyzer, documentCache, configurations) { }
public async Task AutoMerge_HotReload_ClearOperationCaches() { // arrange using var cts = new CancellationTokenSource(20_000); NameString configurationName = "C" + Guid.NewGuid().ToString("N"); var schemaDefinitionV2 = FileResource.Open("AccountSchemaDefinition.json"); IHttpClientFactory httpClientFactory = CreateDefaultRemoteSchemas(configurationName); DocumentNode document = Utf8GraphQLParser.Parse("{ foo }"); var queryHash = "abc"; IDatabase database = _connection.GetDatabase(); while (!cts.IsCancellationRequested) { if (await database.SetLengthAsync(configurationName.Value) == 4) { break; } await Task.Delay(150, cts.Token); } ServiceProvider serviceProvider = new ServiceCollection() .AddSingleton(httpClientFactory) .AddGraphQL() .AddQueryType(d => d.Name("Query").Field("foo").Resolve("foo")) .AddRemoteSchemasFromRedis(configurationName, _ => _connection) .Services .BuildServiceProvider(); IRequestExecutorResolver executorResolver = serviceProvider.GetRequiredService <IRequestExecutorResolver>(); IDocumentCache documentCache = serviceProvider.GetRequiredService <IDocumentCache>(); IPreparedOperationCache preparedOperationCache = serviceProvider.GetRequiredService <IPreparedOperationCache>(); await executorResolver.GetRequestExecutorAsync(cancellationToken : cts.Token); var raised = false; executorResolver.RequestExecutorEvicted += (_, args) => { if (args.Name.Equals(Schema.DefaultName)) { raised = true; } }; Assert.False(documentCache.TryGetDocument(queryHash, out _)); Assert.False(preparedOperationCache.TryGetOperation(queryHash, out _)); IRequestExecutor requestExecutor = await executorResolver.GetRequestExecutorAsync(cancellationToken : cts.Token); await requestExecutor .ExecuteAsync(QueryRequestBuilder .New() .SetQuery(document) .SetQueryHash(queryHash) .Create(), cts.Token); Assert.True(preparedOperationCache.TryGetOperation("_Default-1-abc", out _)); // act await database.StringSetAsync($"{configurationName}.{_accounts}", schemaDefinitionV2); await _connection.GetSubscriber().PublishAsync(configurationName.Value, _accounts); while (!cts.IsCancellationRequested) { if (raised) { break; } await Task.Delay(150, cts.Token); } // assert Assert.True(documentCache.TryGetDocument(queryHash, out _)); Assert.False(preparedOperationCache.TryGetOperation(queryHash, out _)); }
public DocumentDbWithCaching(IDocumentCache cache, IDocumentDb inner) { Cache = cache; Inner = inner; }