-
Notifications
You must be signed in to change notification settings - Fork 93
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
Command current user awareness #75
Comments
We had a similar use-case a while back, we solved it using additional filters. module Mutations
class UserFilter < AdditionalFilter
@default_options = {
with_permission_to: []
}
def filter(data)
...
end
end
end Which can be used in the mutations: class CreateBook < Mutations::Command
required do
user :current_user, with_permission_to: :create_books
end
def execute
...
end
end |
Likewise. That is what I've been doing and I recognize it is a subtle I think in large apps with various levels of users running commands, who is |
@eliank just curious but what does your Just need some more food for thought. The gem I'm working on https://github.com/datapimp/smooth is designed to support a highly declarative style of coding up APIs (the mutations gem obviously helps a ton here) and that snippet you shared pretty much nails how I would like to work in authorization |
Another feature that I've implemented, that I think would be very helpful for users of the mutations gem is current user awareness.
Below is a somewhat contrived example
would be called via:
If you would be interested in supporting this kind of api, I can speak to a number of great benefits over the approach of passing current user as an input.
Let me know and I will prepare a pull request
The text was updated successfully, but these errors were encountered: