public static async Task <HttpResponseData> ExecuteFunctionsQueryAsync( this IGraphQLAzureFunctionsExecutorProxy graphqlExecutorProxy, HttpRequestData httpRequestData, ILogger log = null, CancellationToken cancellationToken = default ) { AssertParamIsNotNull(graphqlExecutorProxy, nameof(graphqlExecutorProxy)); AssertParamIsNotNull(httpRequestData, nameof(httpRequestData)); //Create the GraphQL HttpContext Shim to help marshall data from the Isolated Process HttpRequestData into a // AspNetCore compatible HttpContext, and marshall results back into HttpResponseData from the HttpContext... await using var graphQLHttpContextShim = new GraphQLHttpContextShim(httpRequestData); //Build the Http Context Shim for HotChocolate to consume via the AzureFunctionsProxy... var graphqlHttpContextShim = await graphQLHttpContextShim.CreateGraphQLHttpContextAsync(); //Execute the full HotChocolate middleware pipeline via AzureFunctionsProxy... var logger = log ?? httpRequestData.FunctionContext.GetLogger <IGraphQLAzureFunctionsExecutorProxy>(); await graphqlExecutorProxy.ExecuteFunctionsQueryAsync(graphqlHttpContextShim, logger, cancellationToken).ConfigureAwait(false); //Marshall the results back into the isolated process compatible HttpResponseData... var httpResponseData = await graphQLHttpContextShim.CreateHttpResponseDataAsync().ConfigureAwait(false); return(httpResponseData); }
public async Task <HttpResponseData> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "graphql")] HttpRequestData req, FunctionContext executionContext ) { var logger = executionContext.GetLogger <StarWarsFunctionEndpoint>(); logger.LogInformation("C# GraphQL Request processing via Serverless AzureFunctions (Isolated Process)..."); var response = await _graphqlExecutorProxy.ExecuteFunctionsQueryAsync(req, logger).ConfigureAwait(false); return(response); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "graphql")] HttpRequest req, ILogger logger, CancellationToken cancellationToken ) { logger.LogInformation("C# GraphQL Request processing via Serverless AzureFunctions..."); return(await _graphqlExecutorProxy.ExecuteFunctionsQueryAsync( req.HttpContext, logger, cancellationToken ).ConfigureAwait(false)); }
public async Task <HttpResponseData> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "graphql/bcp/{*path}")] HttpRequestData req, FunctionContext executionContext ) { var logger = executionContext.GetLogger <GraphQLBananaCakePopEndpoint>(); logger.LogInformation("C# GraphQL Request processing via Serverless AzureFunctions (Isolated Process)..."); //SECURE this endpoint against actual Data Queries // This is useful for exposing the GraphQL IDE (Banana Cake Pop) anonymously, but keeping the actual GraphQL data endpoint // secured with AzureFunction token security and/or other authorization approach. if (HttpMethods.IsPost(req.Method) || (HttpMethods.IsGet(req.Method) && !string.IsNullOrWhiteSpace(req.GetQueryStringParam("query")))) { return(req.CreateBadRequestErrorMessageResponse("POST or GET GraphQL queries are invalid for the GraphQL IDE endpoint.")); } var response = await _graphqlExecutorProxy.ExecuteFunctionsQueryAsync(req, logger).ConfigureAwait(false); return(response); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "graphql/playground/{*path}")] HttpRequest req, ILogger logger, CancellationToken cancellationToken ) { logger.LogInformation("C# GraphQL Request processing via Serverless AzureFunctions..."); //SECURE this endpoint against actual Data Queries // This is useful for exposing the playground anonymously, but keeping the actual GraphQL data endpoint // secured with AzureFunction token security and/or other authorization approach. if (HttpMethods.IsPost(req.Method) || (HttpMethods.IsGet(req.Method) && !string.IsNullOrWhiteSpace(req.Query["query"]))) { return(new BadRequestErrorMessageResult("POST or GET GraphQL queries are invalid for the Playground endpoint.")); } return(await _graphqlExecutorProxy.ExecuteFunctionsQueryAsync( req.HttpContext, logger, cancellationToken ).ConfigureAwait(false)); }