action_policy-graphql 0.1.0.rc1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/README.md +4 -4
- data/lib/action_policy/graphql/fields.rb +6 -1
- data/lib/action_policy/graphql/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed3c7c65dee9c9745ebd0725e1468e5c08ed74366af2f6bd834e0f7bc1fd267f
|
4
|
+
data.tar.gz: 2f95fe87eda87024dc848c091889e4455166730fe54e19bfe00866e5d75c3844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1df5623160ccf7c75a2d454b538bb0bbceae39f78a6ca4d2099c77cfada08bedcdd2ec3ad33a66443bb5977f08527bf6a08b60ae645ecf05140e0e2a783a481
|
7
|
+
data.tar.gz: f908810cf5bc1e35151badd82c038910bc6176ab158232e9403533d6801fdf060a5607f0419653b71b8846e51dc86f6697b8d7ce860d525337873f11971314f4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,7 @@ end
|
|
50
50
|
|
51
51
|
You can add authorization to the fields by specifying the `authorize: *` option:
|
52
52
|
|
53
|
-
```
|
53
|
+
```ruby
|
54
54
|
field :home, Home, null: false, authorize: true do
|
55
55
|
argument :id, ID, required: true
|
56
56
|
end
|
@@ -75,7 +75,7 @@ end
|
|
75
75
|
|
76
76
|
You can customize the authorization options, e.g. `authorize: {to: :preview?, with: CustomPolicy}`.
|
77
77
|
|
78
|
-
### `authorized_scope
|
78
|
+
### `authorized_scope: *`
|
79
79
|
|
80
80
|
You can add `authorized_scope: true` option to the field (list or _connection_ field) to
|
81
81
|
apply the corresponding policy rules to the data:
|
@@ -119,8 +119,8 @@ Then the client could perform the following query:
|
|
119
119
|
message
|
120
120
|
# detailed information about the decline reasons; null if value is true
|
121
121
|
reasons {
|
122
|
-
details # JSON-encoded hash of the
|
123
|
-
fullMessages # Array of human-readable reasons
|
122
|
+
details # JSON-encoded hash of the failure reasons (e.g., {"event" => [:seats_available?]})
|
123
|
+
fullMessages # Array of human-readable reasons (e.g., ["This event is sold out"])
|
124
124
|
}
|
125
125
|
}
|
126
126
|
|
@@ -3,6 +3,11 @@
|
|
3
3
|
require "action_policy/graphql/types/authorization_result"
|
4
4
|
|
5
5
|
module ActionPolicy
|
6
|
+
unless "".respond_to?(:then)
|
7
|
+
require "action_policy/ext/yield_self_then"
|
8
|
+
using ActionPolicy::Ext::YieldSelfThen
|
9
|
+
end
|
10
|
+
|
6
11
|
module GraphQL
|
7
12
|
# Add DSL to add policy rules as fields
|
8
13
|
#
|
@@ -22,7 +27,7 @@ module ActionPolicy
|
|
22
27
|
end
|
23
28
|
|
24
29
|
def allowance_to(rule, target = object, **options)
|
25
|
-
policy_for(record: target, **options).
|
30
|
+
policy_for(record: target, **options).then do |policy|
|
26
31
|
policy.apply(authorization_rule_for(policy, rule))
|
27
32
|
policy.result
|
28
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_policy-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
@@ -184,9 +184,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: 2.4.0
|
185
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
|
-
- - "
|
187
|
+
- - ">="
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
189
|
+
version: '0'
|
190
190
|
requirements: []
|
191
191
|
rubygems_version: 3.0.3
|
192
192
|
signing_key:
|