Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Gehrke committed Oct 5, 2017
1 parent 344a778 commit bb821d0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,21 @@ Now, in some cases you'll want to use a different policy, or in case of mutation

```ruby
field :createUser
authorize! :create, User # or User.new; will use UserPolicy#create?
authorize! :create, policy: User # or User.new; will use UserPolicy#create?
resolve ...
end
```

This will use the `:create?` method of the `UserPolicy`. You can also pass in objects instead of a class, if you wish to authorize the user for the specific object.
This will use the `:create?` method of the `UserPolicy`. You can also pass in objects instead of a class (or symbol), if you wish to authorize the user for the specific object.

If you want to pass a different value to the policy, you can use the keyword argument `record`:

```ruby
field :createUser
authorize! :create, record: User.new # or User.new; will use UserPolicy#create?
resolve ...
end
```

You might have also noticed the use of `authorize!` instead of `authorize` in this example. The difference between the two is this:

Expand Down

0 comments on commit bb821d0

Please sign in to comment.