public async Task <IActionResult> PrivateEntityQuery(QueryRequestDto dto)
 {
     if (await _pvtEntityApiClientService.RaiseQueryAsync(_mapper.Map <RaisedQueryRequestDto>(dto)))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Esempio n. 2
0
        CreateQueryRequestAsync(HttpContext context)
        {
            QueryRequestDto request = await ReadRequestAsync(context)
                                      .ConfigureAwait(false);

            return(QueryRequestBuilder.New()
                   .SetQuery(request.Query)
                   .SetOperation(request.OperationName)
                   .SetVariableValues(
                       QueryMiddlewareUtilities.ToDictionary(request.Variables)));
        }
Esempio n. 3
0
        CreateQueryRequestAsync(HttpContext context)
        {
            QueryRequestDto request = ReadRequest(context);

            return(Task.FromResult(
                       QueryRequestBuilder.New()
                       .SetQuery(request.Query)
                       .SetOperation(request.OperationName)
                       .SetVariableValues(QueryMiddlewareUtilities
                                          .ToDictionary(request.Variables))));
        }
Esempio n. 4
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. 7
0
        public async Task HandleAsync(
            IWebSocketContext context,
            GenericOperationMessage message,
            CancellationToken cancellationToken)
        {
            QueryRequestDto payload = message.Payload.ToObject <QueryRequestDto>();

            IQueryRequestBuilder requestBuilder =
                QueryRequestBuilder.New()
                .SetQuery(payload.Query)
                .SetOperation(payload.OperationName)
                .SetVariableValues(QueryMiddlewareUtilities
                                   .ToDictionary(payload.Variables))
                .SetServices(context.HttpContext.CreateRequestServices());

            await context.PrepareRequestAsync(requestBuilder)
            .ConfigureAwait(false);

            IExecutionResult result =
                await context.QueryExecutor.ExecuteAsync(
                    requestBuilder.Create(), cancellationToken)
                .ConfigureAwait(false);

            if (result is IResponseStream responseStream)
            {
                context.RegisterSubscription(
                    new Subscription(context, responseStream, message.Id));
            }
            else if (result is IReadOnlyQueryResult queryResult)
            {
                await context.SendSubscriptionDataMessageAsync(
                    message.Id, queryResult, cancellationToken)
                .ConfigureAwait(false);

                await context.SendSubscriptionCompleteMessageAsync(
                    message.Id, cancellationToken)
                .ConfigureAwait(false);
            }
        }