Esempio n. 1
0
        private async Task HandleRequestAsync(
            HttpContext context,
            IQueryExecutor queryExecutor)
        {
#if ASPNETCLASSIC
            if (_accessor != null)
            {
                _accessor.OwinContext = context;
            }

            using (IServiceScope serviceScope =
                Executor.Schema.Services.CreateScope())
            {
                IServiceProvider serviceProvider =
                    context.CreateRequestServices(
                        serviceScope.ServiceProvider);
#else
            IServiceProvider serviceProvider = context.RequestServices;
#endif

            IReadOnlyQueryRequest request =
                await CreateQueryRequestInternalAsync(context, serviceProvider)
                    .ConfigureAwait(false);

                IExecutionResult result = await queryExecutor
                    .ExecuteAsync(request, context.GetCancellationToken())
                    .ConfigureAwait(false);

                await WriteResponseAsync(context.Response, result)
                    .ConfigureAwait(false);
#if ASPNETCLASSIC
            }
#endif
        }
Esempio n. 2
0
        CreateQueryRequestAsync(HttpContext context)
        {
            QueryRequestDto request = await ReadRequestAsync(context)
                                      .ConfigureAwait(false);

#if ASPNETCLASSIC
            IServiceProvider serviceProvider = context.CreateRequestServices(
                Executor.Schema.Services);
#else
            IServiceProvider serviceProvider = context.CreateRequestServices();
#endif
            return(QueryRequestBuilder.New()
                   .SetQuery(request.Query)
                   .SetOperation(request.OperationName)
                   .SetVariableValues(
                       QueryMiddlewareUtilities.ToDictionary(request.Variables))
                   .SetServices(serviceProvider));
        }
        protected override async Task <QueryRequest> CreateQueryRequest(
            HttpContext context)
        {
            QueryRequestDto request = await ReadRequestAsync(context)
                                      .ConfigureAwait(false);

#if ASPNETCLASSIC
            IServiceProvider serviceProvider = context.CreateRequestServices(
                Services);
#else
            IServiceProvider serviceProvider = context.CreateRequestServices();
#endif

            return(new QueryRequest(request.Query, request.OperationName)
            {
                VariableValues = QueryMiddlewareUtilities
                                 .ToDictionary(request.Variables),
                Services = serviceProvider
            });
        }
        /// <inheritdoc />
        protected override Task <QueryRequest> CreateQueryRequest(
            HttpContext context)
        {
            QueryRequestDto request = ReadRequest(context);

#if ASPNETCLASSIC
            IServiceProvider serviceProvider = context.CreateRequestServices(
                Services);
#else
            IServiceProvider serviceProvider = context.CreateRequestServices();
#endif

            return(Task.FromResult(
                       new QueryRequest(request.Query, request.OperationName)
            {
                VariableValues = QueryMiddlewareUtilities
                                 .ToDictionary(request.Variables),
                Services = serviceProvider
            }));
        }
Esempio n. 5
0
        private async Task HandleRequestAsync(
            HttpContext context)
        {
            if (_accessor != null)
            {
                _accessor.OwinContext = context;
            }

            using (IServiceScope serviceScope = _services.CreateScope())
            {
                IServiceProvider services =
                    context.CreateRequestServices(
                        serviceScope.ServiceProvider);

                await ExecuteRequestAsync(context, services)
                .ConfigureAwait(false);
            }
        }