graphql_authorize 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 732b017c569a30cddfb6e469248a6f297f094cb37503c65ddbb9d719f9f2c0bb
4
- data.tar.gz: 8721619c78ff9b30f1bc6410537ffcca63910a9a0a3dfdcbd2a80df87960f8dd
3
+ metadata.gz: 26fa4a306873ecd6f5b46181bcdf84b866f694cdfc7b884a6f2245f5d84c01ce
4
+ data.tar.gz: 116b527dc74e150fc3bff7e1e764c4d2e617ecec329250eb1dbc84ed0395b5b7
5
5
  SHA512:
6
- metadata.gz: 69421bd51dfd5c3acfe6ab359ab1d54dfa6da0a7c5c345eccc5bb98ae2930cf16065d6fee22caf72640071c0a3cb44dd33c9092e23bfb3149246b736ac888247
7
- data.tar.gz: 1e54e9fa06f4b5a91acd1567e3bde40adfa46dcb1c12879156cf18bd2158e850477769b10421e4621eee7db83062862f038d9e99ae93d2cf41063c0ad1dcadf7
6
+ metadata.gz: de97f75b032523244d8987901768f01ab81eec872783b1ecef9ae5b9a6b4fb8a418e58024f24b0c2307e143533b71ea44f43cc27b7f2baa1c2c46e5034985513
7
+ data.tar.gz: 7b75660cd47953401b9f8f337f5bfb5d8faec7749d4229107754455184f6f06a2293e119948368c1142b9f06e5b3a020c0ef61bb710ee8032e3cd0ada5ae3313
data/.travis.yml CHANGED
@@ -16,10 +16,3 @@ matrix:
16
16
  gemfile: gemfiles/graphql-1.7.gemfile
17
17
  - rvm: 2.3.1
18
18
  gemfile: gemfiles/graphql-1.6.gemfile
19
- allow_failures:
20
- - rvm: ruby-head
21
- gemfile: gemfiles/graphql-1.8.gemfile
22
- - rvm: 2.5.0
23
- gemfile: gemfiles/graphql-1.8.gemfile
24
- - rvm: 2.4.3
25
- gemfile: gemfiles/graphql-1.7.gemfile
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Change log
2
+
3
+ ## master
4
+
5
+ ## 0.2.0 (2018-09-20)
6
+
7
+ - [PR [#6](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/6)] Support GraphQL class syntax ([@DmitryTsepelev][])
8
+
9
+ ## 0.1.1 (2018-09-17)
10
+
11
+ - Initial version. ([@DmitryTsepelev][], [@serggl][])
12
+
13
+ [@DmitryTsepelev]: https://github.com/DmitryTsepelev
14
+ [@serggl]: https://github.com/serggl
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql_authorize (0.1.1)
5
- graphql (~> 1.6)
4
+ graphql_authorize (0.2.0)
5
+ graphql (>= 1.6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  # GraphqlAuthorize
4
4
 
5
5
 
6
- 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 :(
6
+ This gem allows you to authorize an access to you graphql-fields (defined by [graphql-ruby](https://github.com/rmosolgo/graphql-ruby)).
7
7
 
8
8
  ## Installation
9
9
 
@@ -36,6 +36,17 @@ field :posts, types[PostType] do
36
36
  end
37
37
  ```
38
38
 
39
+ It also works for a new class-based syntax:
40
+
41
+ ```ruby
42
+ field :posts, PostType, null: false do
43
+ authorize lambda { |_obj, _args, context|
44
+ current_user = context[:current_user]
45
+ current_user && current_user.admin
46
+ }
47
+ end
48
+ ```
49
+
39
50
  Don't forget to pass `current_user` to the context when you execute the query, e.g.:
40
51
 
41
52
  ```ruby
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.required_ruby_version = ">= 2.3"
27
27
 
28
- spec.add_dependency "graphql", "~> 1.6"
28
+ spec.add_dependency "graphql", ">= 1.6"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.16"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
@@ -7,7 +7,9 @@ require "graphql_authorize/configuration"
7
7
  require "graphql_authorize/auth_adapters/base"
8
8
  require "graphql_authorize/auth_adapters/can_can_can"
9
9
  require "graphql_authorize/auth_adapters/pundit"
10
+
10
11
  require "graphql_authorize/ext/field"
12
+ require "graphql_authorize/ext/schema_field"
11
13
  require "graphql_authorize/ext/field_resolve_step"
12
14
 
13
15
  module GraphqlAuthorize
@@ -19,10 +21,16 @@ module GraphqlAuthorize
19
21
  def configure
20
22
  yield config
21
23
  end
24
+
25
+ def supports_class_syntax?
26
+ Gem.loaded_specs["graphql"].version >= Gem::Version.create("1.8")
27
+ end
22
28
  end
23
29
 
24
30
  GraphQL::Field.include(GraphqlAuthorize::Field)
25
31
 
32
+ GraphQL::Schema::Field.include(GraphqlAuthorize::SchemaField) if supports_class_syntax?
33
+
26
34
  GraphQL::Execution::Execute::FieldResolveStep.singleton_class.prepend(
27
35
  GraphqlAuthorize::FieldResolveStep
28
36
  )
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphqlAuthorize
4
+ module SchemaField
5
+ def self.included(base)
6
+ base.accepts_definition :authorize
7
+ end
8
+
9
+ attr_accessor :authorize
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlAuthorize
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_authorize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-17 00:00:00.000000000 Z
11
+ date: 2018-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
@@ -132,6 +132,7 @@ files:
132
132
  - ".gitignore"
133
133
  - ".rubocop.yml"
134
134
  - ".travis.yml"
135
+ - CHANGELOG.md
135
136
  - Gemfile
136
137
  - Gemfile.lock
137
138
  - LICENSE.txt
@@ -150,6 +151,7 @@ files:
150
151
  - lib/graphql_authorize/configuration.rb
151
152
  - lib/graphql_authorize/ext/field.rb
152
153
  - lib/graphql_authorize/ext/field_resolve_step.rb
154
+ - lib/graphql_authorize/ext/schema_field.rb
153
155
  - lib/graphql_authorize/version.rb
154
156
  homepage: https://github.com/anjlab/graphql_authorize
155
157
  licenses: