Last active
February 13, 2022 22:03
-
-
Save xperiandri/98aa90c161faa12a9536f99584d79ad9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// F# | |
type public GraphQLFunction (serviceProvider : IServiceProvider, log : ILogger<GraphQLFunction>) = | |
[<FunctionName "GraphQL">] | |
member public __.Execute | |
([<HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = null)>] req : HttpRequest, | |
cancellationToken : CancellationToken) = Async.StartAsTask (async { | |
let! responseData = GraphQL.handleRequest serviceProvider req.Body | |
let responseBody = GraphQLFunction.GetBody log responseData | |
return JsonResult (responseBody) | |
}, cancellationToken = cancellationToken) | |
// C# | |
public class GraphQLFunction (IServiceProvider: serviceProvider, ILogger<GraphQLFunction>: log) | |
{ | |
[FunctionName("GraphQL")] | |
public Task Execute | |
([HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = null)] HttpRequest: req, | |
CancellationToken: cancellationToken) | |
{ | |
var responseData = await GraphQL.HandleRequest(serviceProvider, req.Body, cancellationToken) | |
var responseBody = GraphQLFunction.GetBody(log, responseData) | |
return new JsonResult (responseBody) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment