コード例 #1
0
    protected static async Task <IBatchQueryResult> ExecuteOperationBatchAsync(
        HttpContext context,
        IRequestExecutor requestExecutor,
        IHttpRequestInterceptor requestInterceptor,
        IServerDiagnosticEvents diagnosticEvents,
        GraphQLRequest request,
        IReadOnlyList <string> operationNames)
    {
        diagnosticEvents.StartOperationBatchRequest(context, request, operationNames);

        var requestBatch = new IReadOnlyQueryRequest[operationNames.Count];

        for (var i = 0; i < operationNames.Count; i++)
        {
            QueryRequestBuilder requestBuilder = QueryRequestBuilder.From(request);
            requestBuilder.SetOperation(operationNames[i]);

            await requestInterceptor.OnCreateAsync(
                context, requestExecutor, requestBuilder, context.RequestAborted);

            requestBatch[i] = requestBuilder.Create();
        }

        return(await requestExecutor.ExecuteBatchAsync(
                   requestBatch, cancellationToken : context.RequestAborted));
    }
コード例 #2
0
        protected async Task <IExecutionResult> ExecuteSingleAsync(
            HttpContext context,
            IRequestExecutor requestExecutor,
            IHttpRequestInterceptor requestInterceptor,
            GraphQLRequest request)
        {
            QueryRequestBuilder requestBuilder = QueryRequestBuilder.From(request);

            await requestInterceptor.OnCreateAsync(
                context, requestExecutor, requestBuilder, context.RequestAborted);

            return(await requestExecutor.ExecuteAsync(
                       requestBuilder.Create(), context.RequestAborted));
        }
コード例 #3
0
    protected static async Task <IExecutionResult> ExecuteSingleAsync(
        HttpContext context,
        IRequestExecutor requestExecutor,
        IHttpRequestInterceptor requestInterceptor,
        IServerDiagnosticEvents diagnosticEvents,
        GraphQLRequest request,
        OperationType[]?allowedOperations = null)
    {
        diagnosticEvents.StartSingleRequest(context, request);

        var requestBuilder = QueryRequestBuilder.From(request);

        requestBuilder.SetAllowedOperations(allowedOperations);

        await requestInterceptor.OnCreateAsync(
            context, requestExecutor, requestBuilder, context.RequestAborted);

        return(await requestExecutor.ExecuteAsync(
                   requestBuilder.Create(), context.RequestAborted));
    }
コード例 #4
0
        protected async Task <IBatchQueryResult> ExecuteBatchAsync(
            HttpContext context,
            IRequestExecutor requestExecutor,
            IHttpRequestInterceptor requestInterceptor,
            IReadOnlyList <GraphQLRequest> requests)
        {
            var requestBatch = new IReadOnlyQueryRequest[requests.Count];

            for (var i = 0; i < requests.Count; i++)
            {
                QueryRequestBuilder requestBuilder = QueryRequestBuilder.From(requests[0]);

                await requestInterceptor.OnCreateAsync(
                    context, requestExecutor, requestBuilder, context.RequestAborted);

                requestBatch[i] = requestBuilder.Create();
            }

            return(await requestExecutor.ExecuteBatchAsync(
                       requestBatch, cancellationToken : context.RequestAborted));
        }