public static IApplicationBuilder UseGraphQLHttpGet(
            this IApplicationBuilder applicationBuilder,
            IServiceProvider serviceProvider,
            IHttpGetMiddlewareOptions 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>();

            IQueryResultSerializer serializer = serviceProvider
                                                .GetRequiredService <IQueryResultSerializer>();

            OwinContextAccessor contextAccessor =
                serviceProvider.GetService <OwinContextAccessor>();

            return(applicationBuilder.Use <HttpGetMiddleware>(
                       options, contextAccessor, executor, serializer));
        }
Beispiel #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));
        }