Skip to content

Navigation Menu

Sign in
Sign up

Map userWarning to userError #1007

ivanaareon started this conversation in General
Discussion options

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.

image

Thanks in advance.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /