graphql_authorize 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -7
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +2 -2
- data/README.md +12 -1
- data/graphql_authorize.gemspec +1 -1
- data/lib/graphql_authorize.rb +8 -0
- data/lib/graphql_authorize/ext/schema_field.rb +11 -0
- data/lib/graphql_authorize/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26fa4a306873ecd6f5b46181bcdf84b866f694cdfc7b884a6f2245f5d84c01ce
|
4
|
+
data.tar.gz: 116b527dc74e150fc3bff7e1e764c4d2e617ecec329250eb1dbc84ed0395b5b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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)).
|
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
|
data/graphql_authorize.gemspec
CHANGED
@@ -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", "
|
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"
|
data/lib/graphql_authorize.rb
CHANGED
@@ -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
|
)
|
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.
|
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-
|
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:
|