Open
Description
I am using graphql-dotnet in dotnet 6, Need to get argument from the query/mutation for authentication. In AuthorizationHandler how to extract the values from query.
This is a sample query
{
formQuery {
form(id: 1, organisationId: "string") {
id
name
organisationId
}
}
}
How to parse formId
and organisationId
from query?
This is my implementation
public class ValidOrganisationHandler : AuthorizationHandler<ValidOrganisationRequirement>
{
private readonly IHttpContextAccessor _httpContextAccessor;
public ValidOrganisationHandler(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context,
ValidOrganisationRequirement requirement)
{
if (_httpContextAccessor.HttpContext != null)
{
// How to get value from graphql query/mutation
if (/*parsed value*/)
{
context.Succeed(requirement);
}
else
{
context.Fail();
}
}
else
{
context.Fail();
}
context.Succeed(requirement);
// return Task.CompletedTask;
}
Metadata
Metadata
Assignees
Labels
No labels