-
-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BREAKING CHANGE 🚨] Change arguments for authorize
#489
Conversation
268b7ae
to
d3f8ba3
Compare
$arguments = func_get_args(); | ||
|
||
// Get all given arguments | ||
if (! is_null($arguments[2]) && is_array($arguments[2])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, see PR desciption
// Validate mutation arguments | ||
if (method_exists($this, 'getRules')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -201,6 +199,11 @@ protected function getResolver(): ?Closure | |||
}; | |||
} | |||
|
|||
// Authorize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved down from before "selects and relations" block to include SelectFields too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to change it like this. How will we version it now - 3.0?
Yes, absolutely has to be! Actually also for #487 => changing the behaviour what kind of exception will be "reported" is also breaking semvar (IMHO / AFAIK) |
d3f8ba3
to
ae1c826
Compare
1d08974
to
0dfe387
Compare
0dfe387
to
b4f8643
Compare
For background, see #481 and specifically #481 (comment) and further comments.
The basic change:
public function authorize(array $args): bool
public function authorize($root, array $args, $ctx, ResolveInfo $resolveInfo = null, Closure $getSelectFields = null): bool
The astute reader will recognize that these are exactly the same arguments passed to
resolve
, and this isn't a coincidence.This is also made even clearer in the small refactor I did in the code regarding calling them:
The only difference is that checking if the returned value and the (automatic) reaction to it (this fact was never different, but due to aligning the arguments it's now even more clear how this works).
Additional changes:
$arguments[2]
(context) into$arguments[1]
(args), this seems like a strange thing to do, another one of those implicit behaviours without clear indication as to way (blame didn't offer me much more insights)method_exists
forgetRules
, that method is already there and can never be "not there"TODO