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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9b7415b2d65e1530b8e56c4981759200f341bf15aa5fb6e6ceebc08c806821f
4
- data.tar.gz: 4708e50afcb152a7a7cb2b32f6c26d74a69412bea0d1575c96cdde396d596ac8
3
+ metadata.gz: b4eee6371389b2dc2b666235993adb716b2edaddb327e6f6a7676bbfbde909d8
4
+ data.tar.gz: 1e2d08f7882d72926842d76335f165621a3685b93a541e27c85bda12be5c4c8c
5
5
  SHA512:
6
- metadata.gz: 01beff2971f13a64651d3170bde7a0b11396a9fb797bc4dfb8d95560af14bfec55144dd03de0a712344e4cd1aed0c3206964ac09e12a08beab452293d1710e6c
7
- data.tar.gz: 4bea766a1789a5228777ea218aabeed5e50c06585d0259989bb97677ff3d0c0cf28b65497d21c35caf3a8e07d742c0c50888917762d563d53999dc1eb2a8d897
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)
@@ -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
@@ -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
@@ -3,6 +3,6 @@
3
3
 
4
4
  module HQ
5
5
  module GraphQL
6
- VERSION = "2.0.2"
6
+ VERSION = "2.0.3"
7
7
  end
8
8
  end
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.2
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-10-29 00:00:00.000000000 Z
11
+ date: 2019-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails