README.md in graphql_authorize-0.1.1 vs README.md in graphql_authorize-0.2.0
- old
+ new
@@ -1,11 +1,11 @@
[](https://travis-ci.org/anjlab/graphql_authorize)
# GraphqlAuthorize
-This gem allows you to authorize an access to you graphql-fields (defined by [graphql-ruby](https://github.com/rmosolgo/graphql-ruby)). For now, we support only 1.6 version :(
+This gem allows you to authorize an access to you graphql-fields (defined by [graphql-ruby](https://github.com/rmosolgo/graphql-ruby)).
## Installation
Add this line to your application's Gemfile:
@@ -31,9 +31,20 @@
current_user = context[:current_user]
current_user && current_user.admin
}
resolve ->(_obj, _args, _context) { ... }
+end
+```
+
+It also works for a new class-based syntax:
+
+```ruby
+field :posts, PostType, null: false do
+ authorize lambda { |_obj, _args, context|
+ current_user = context[:current_user]
+ current_user && current_user.admin
+ }
end
```
Don't forget to pass `current_user` to the context when you execute the query, e.g.: