-
Notifications
You must be signed in to change notification settings - Fork 225
Map userWarning to userError #1007
ivanaareon
started this conversation in
General
Hello,
When I use user validation for GQL calls with "isGranted()" config, for query type queries (not mutations) I'm getting a warning instead of an error in the response. I'd need to force this warnings turns into errors, but I can't find the way.
access: '@=isGranted( "whatever", [args["id"]] )'
Does anyone have any idea on how to approach this issue?
This is the vendor portion of code involved.
UserWarning::class
vendor/overblog/graphql-bundle/src/Resolver/AccessResolver.php:60
private function checkAccessForStrictMode(callable $accessChecker, callable $resolveCallback, array $resolveArgs = [])
{
$promiseOrHasAccess = $this->hasAccess($accessChecker, $resolveArgs);
$callback = function ($hasAccess) use ($resolveArgs, $resolveCallback) {
if (true === $hasAccess) {
return \call_user_func_array($resolveCallback, $resolveArgs);
}
$exceptionClassName = self::isMutationRootField($resolveArgs[3]) ? UserError::class : UserWarning::class;
throw new $exceptionClassName('Access denied to this field (2).');
};
if ($this->isThenable($promiseOrHasAccess)) {
return $this->createPromise($promiseOrHasAccess, $callback);
} else {
return $callback($promiseOrHasAccess);
}
}
And this is the response, where I'd need a "error" group, instead of warning.
Thanks in advance.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment