예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        public static IApplicationBuilder UseGraphQLHttpPost(
            this IApplicationBuilder applicationBuilder,
            IHttpPostMiddlewareOptions options)
        {
            if (applicationBuilder == null)
            {
                throw new ArgumentNullException(nameof(applicationBuilder));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(applicationBuilder
                   .UseMiddleware <HttpPostMiddleware>(options));
        }