graphql-pundit 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql-pundit/instrumenters/scope.rb +19 -6
- data/lib/graphql-pundit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c8cfdd5652e733a3ccf9160bd6671d6f4e4936a
|
4
|
+
data.tar.gz: c0ca0b99379ec209201fa08ed543517f031dd8ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2764f622ac9f231d910550114cc6706fbba50c324ad07aea103d01916c281928ba7035691804bfc3b1431877aa188cec94ddb3287ce45bd6f39364b31d1eded0
|
7
|
+
data.tar.gz: c7c685e2e16c836039afebafad18edd91896756766fd6b67584bdf608162a7b5994de573b4be48326f0ef685dfdf61b823c2f5a080fb1ba2131e9025523ba2f3
|
@@ -19,11 +19,12 @@ module GraphQL
|
|
19
19
|
raise ArgumentError, 'Invalid value passed to `scope`'
|
20
20
|
end
|
21
21
|
|
22
|
-
@scope =
|
22
|
+
@scope = scope
|
23
23
|
end
|
24
24
|
|
25
25
|
def call(root, arguments, context)
|
26
|
-
|
26
|
+
scope_proc = new_scope(scope)
|
27
|
+
new_scope = scope_proc.call(root, arguments, context)
|
27
28
|
old_resolver.call(new_scope, arguments, context)
|
28
29
|
end
|
29
30
|
|
@@ -33,11 +34,23 @@ module GraphQL
|
|
33
34
|
return scope if proc?(scope)
|
34
35
|
|
35
36
|
lambda do |root, _arguments, context|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
scope = find_scope(root, scope)
|
38
|
+
scope.new(context[current_user], root).resolve
|
39
|
+
end
|
40
|
+
end
|
39
41
|
|
40
|
-
|
42
|
+
def find_scope(root, scope)
|
43
|
+
if !inferred?(scope)
|
44
|
+
scope::Scope
|
45
|
+
else
|
46
|
+
# Special case for Sequel datasets that do not respond to
|
47
|
+
# ActiveModel's model_name
|
48
|
+
infer_from = if root.respond_to?(:model)
|
49
|
+
root.model
|
50
|
+
else
|
51
|
+
root
|
52
|
+
end
|
53
|
+
::Pundit::PolicyFinder.new(infer_from).scope!
|
41
54
|
end
|
42
55
|
end
|
43
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-pundit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ontohub Core Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|