public async Task <IActionResult> Post([FromBody] GraphQLQuery query) { _logger.LogInformation("Executing GraphQL"); if (query == null) { throw new ArgumentNullException(nameof(query)); } var inputs = query.Variables.ToInputs(); var executionOptions = new ExecutionOptions { Schema = _schema, Query = query.Query, Inputs = inputs }; var result = await _documentExecuter.ExecuteAsync(executionOptions).ConfigureAwait(false); if (result.Errors?.Count > 0) { return(BadRequest(result)); } return(Ok(result)); }
public async Task <IActionResult> Post([FromBody] GraphQLQuery query) { var schema = new Schema { Query = new DemoQuery() }; var result = await new DocumentExecuter().ExecuteAsync(_ => { _.Schema = schema; _.Query = query.Query; }).ConfigureAwait(false); if (result.Errors?.Count > 0) { return(BadRequest()); } return(Ok(result)); }