I'm using GraphQL.net with C#. I have a Field within an ObjectGraphType that looks something like this;
Field<FooGraphType>(
"baz",
resolve: context =>
{
//I want to inspect the Request object here
});
The one and only endpoint I have looks like this;
[HttpPost]
public async Task<IActionResult> Post([FromBody] GraphQLQuery query)
{
// I can access the Request object here
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);
}
How can I let the resolve function of my ObjectGraphType field gain access to the HttpRequest object found in the controller action? Although I am interested in getting the entire HttpRequest object, being able to pass specific pieces of information from the Request into the resolve function would be sufficient.