public async Task<HttpResponseMessage> PostAsync(HttpRequestMessage request, GraphQLQuery query) { var inputs = query.Variables.ToInputs(); var queryToExecute = query.Query; if (!string.IsNullOrWhiteSpace(query.NamedQuery)) { queryToExecute = _namedQueries[query.NamedQuery]; } var result = await _executer.ExecuteAsync(_ => { _.Schema = _schema; _.Query = queryToExecute; _.OperationName = query.OperationName; _.Inputs = inputs; _.ComplexityConfiguration = new ComplexityConfiguration { MaxDepth = 15 }; _.FieldMiddleware.Use<InstrumentFieldsMiddleware>(); }).ConfigureAwait(false); var httpResult = result.Errors?.Count > 0 ? HttpStatusCode.BadRequest : HttpStatusCode.OK; var json = _writer.Write(result); var response = request.CreateResponse(httpResult); response.Content = new StringContent(json, Encoding.UTF8, "application/json"); return response; }
public async Task <HttpResponseMessage> Post(HttpRequestMessage request, GraphQLQuery query) { var inputs = query.Variables.ToInputs(); var result = await Execute(_schema, null, query.Query, query.OperationName, inputs); var httpResult = result.Errors?.Count > 0 ? HttpStatusCode.BadRequest : HttpStatusCode.OK; var json = _writer.Write(result); var response = request.CreateResponse(httpResult); response.Content = new StringContent(json, Encoding.UTF8, "application/json"); return(response); }
public async Task<HttpResponseMessage> PostAsync(HttpRequestMessage request, GraphQLQuery query) { var inputs = query.Variables.ToInputs(); var queryToExecute = query.Query; if (!string.IsNullOrWhiteSpace(query.NamedQuery)) { queryToExecute = _namedQueries[query.NamedQuery]; } var result = await ExecuteAsync(_schema, null, queryToExecute, query.OperationName, inputs).ConfigureAwait(true); var httpResult = result.Errors?.Count > 0 ? HttpStatusCode.BadRequest : HttpStatusCode.OK; var json = _writer.Write(result); var response = request.CreateResponse(httpResult); response.Content = new StringContent(json, Encoding.UTF8, "application/json"); return response; }
public async Task <ExecutionResult> Post(GraphQLQuery query) { return(await Execute(_schema, null, query.Query)); }
public async Task <HttpResponseMessage> PostAsync(HttpRequestMessage request, GraphQLQuery query) { var inputs = query.Variables.ToInputs(); var queryToExecute = query.Query; if (!string.IsNullOrWhiteSpace(query.NamedQuery)) { queryToExecute = _namedQueries[query.NamedQuery]; } var result = await _executer.ExecuteAsync(_ => { _.Schema = _schema; _.Query = queryToExecute; _.OperationName = query.OperationName; _.Inputs = inputs; _.ComplexityConfiguration = new ComplexityConfiguration { MaxDepth = 15 }; _.FieldMiddleware.Use <InstrumentFieldsMiddleware>(); }).ConfigureAwait(false); var httpResult = result.Errors?.Count > 0 ? HttpStatusCode.BadRequest : HttpStatusCode.OK; var json = _writer.Write(result); var response = request.CreateResponse(httpResult); response.Content = new StringContent(json, Encoding.UTF8, "application/json"); return(response); }
public async Task<ExecutionResult> Post(GraphQLQuery query) { return await Execute(_schema, null, query.Query); }
public async Task <HttpResponseMessage> PostAsync(HttpRequestMessage request, GraphQLQuery query) { var inputs = query.Variables.ToInputs(); var queryToExecute = query.Query; var result = await _executer.ExecuteAsync(_ => { _.Schema = _schema; _.Query = queryToExecute; _.OperationName = query.OperationName; _.Inputs = inputs; _.ComplexityConfiguration = new ComplexityConfiguration { MaxDepth = 15 }; }).ConfigureAwait(false); var httpResult = result.Errors?.Count > 0 ? HttpStatusCode.BadRequest : HttpStatusCode.OK; var json = await _writer.WriteToStringAsync(result); var response = request.CreateResponse(httpResult); response.Content = new StringContent(json, Encoding.UTF8, "application/json"); return(response); }
public async Task <HttpResponseMessage> PostAsync(HttpRequestMessage request, GraphQLQuery query) { var inputs = query.Variables.ToInputs(); var queryToExecute = query.Query; if (!string.IsNullOrWhiteSpace(query.NamedQuery)) { queryToExecute = _namedQueries[query.NamedQuery]; } var result = await ExecuteAsync(_schema, null, queryToExecute, query.OperationName, inputs).ConfigureAwait(true); var httpResult = result.Errors?.Count > 0 ? HttpStatusCode.BadRequest : HttpStatusCode.OK; var json = _writer.Write(result); var response = request.CreateResponse(httpResult); response.Content = new StringContent(json, Encoding.UTF8, "application/json"); return(response); }
public ExecutionResult Post(GraphQLQuery query) { return Execute(_schema, null, query.Query); }