hq-graphql 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hq/graphql.rb +5 -0
- data/lib/hq/graphql/config.rb +3 -0
- data/lib/hq/graphql/object.rb +4 -0
- data/lib/hq/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4eee6371389b2dc2b666235993adb716b2edaddb327e6f6a7676bbfbde909d8
|
4
|
+
data.tar.gz: 1e2d08f7882d72926842d76335f165621a3685b93a541e27c85bda12be5c4c8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c32bc6d94598f571f5b679efeab6d67ba1a3656f41c4c669c615ee414bae2d780bb2de80a92a11ceda730af49297a1418da4d448b843b17daf540ce9f89f2b
|
7
|
+
data.tar.gz: 9b42478cf51ad1e48f84604526caec0d1fc7d993f32f3e7f09fefd8299a911ca77a136fd4b1d11f52fed722afe61510f44c72c3d99e8f3d6fc246ecc0c9732d7
|
data/lib/hq/graphql.rb
CHANGED
@@ -23,6 +23,11 @@ module HQ
|
|
23
23
|
config.instance_eval(&block)
|
24
24
|
end
|
25
25
|
|
26
|
+
sig { params(object: T.untyped, context: ::GraphQL::Query::Context).returns(T::Boolean) }
|
27
|
+
def self.authorized?(object, context)
|
28
|
+
config.authorize.call(object, context)
|
29
|
+
end
|
30
|
+
|
26
31
|
sig { params(scope: T.untyped, context: ::GraphQL::Query::Context).returns(T.untyped) }
|
27
32
|
def self.default_scope(scope, context)
|
28
33
|
config.default_scope.call(scope, context)
|
data/lib/hq/graphql/config.rb
CHANGED
@@ -7,6 +7,9 @@ module HQ
|
|
7
7
|
class Config < T::Struct
|
8
8
|
DefaultScopeProc = T.type_alias { T.proc.params(arg0: T.untyped, arg1: ::GraphQL::Query::Context).returns(T.untyped) }
|
9
9
|
prop :default_scope, DefaultScopeProc, default: ->(scope, _context) { scope }
|
10
|
+
|
11
|
+
AuthorizeProc = T.type_alias { T.proc.params(arg0: T.untyped, arg1: ::GraphQL::Query::Context).returns(T::Boolean) }
|
12
|
+
prop :authorize, AuthorizeProc, default: ->(_object, _context) { true }
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
data/lib/hq/graphql/object.rb
CHANGED
@@ -9,6 +9,10 @@ module HQ
|
|
9
9
|
|
10
10
|
field_class ::HQ::GraphQL::Field::AssociationLoader
|
11
11
|
|
12
|
+
def self.authorized?(object, context)
|
13
|
+
super && ::HQ::GraphQL.authorized?(object, context)
|
14
|
+
end
|
15
|
+
|
12
16
|
def self.with_model(model_name, attributes: true, associations: true, auto_nil: true)
|
13
17
|
self.model_name = model_name
|
14
18
|
self.auto_load_attributes = attributes
|
data/lib/hq/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hq-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|