You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
The text was updated successfully, but these errors were encountered:
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
How to parse
formId
andorganisationId
from query?This is my implementation
The text was updated successfully, but these errors were encountered: