action_policy-graphql 0.5.2 → 0.5.4

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: 5126db7b4d19dd644abae6e400e40b0c2a9c7860da2851eb13644bdf247e4b5a
4
- data.tar.gz: cffccd7267712826f13ac8e53475f24ad56532a1c090d1c9e74b6797c7081123
3
+ metadata.gz: cbcbb5943f46f12ea7f7941986a35c6bccb7cdbb4dabc412bad172cad69fc2fa
4
+ data.tar.gz: 3080d536b2fd332526ef247097374eac0254a1a7ff15c9fea1ae90d622a2e2d4
5
5
  SHA512:
6
- metadata.gz: a20f415b4200c130e32c2a04adecd647cd6c466ddd355e48e2ac0059b912701dca0d2cdde9c791ba40d1b83d3916de55dff89bf698058399925cbe8de05025ea
7
- data.tar.gz: 5ffa1734654b633f935d7897316497e84fb8dfa8f9b13cf1f6eea7b50d622a21bcc448aae03711bbfc0cee09f7ca0385b168fbc20854e22e42c2de5f2ccf3683
6
+ metadata.gz: 1cbb934cd6b7cd5699149281484b3642af7be899a362712614018a146bc951db298a8c8d5ea278d3312d92f614ca4c10d1b376d0d351ea24f654a9b465d59a03
7
+ data.tar.gz: eafccbc78d510fe23397fb7f166bdbf5b51275b22ff75b40f0c70d9f5910d050b16b0382ebab0ec3f16db22ebc4ce4d171defc336e38710101856ed736a33e88
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.5.4 (2023-12-22)
6
+
7
+ - Do not mutate passed field options. ([@palkan][])
8
+
9
+ Fixes compatibility with `with_options` approach.
10
+
11
+ ## 0.5.3 (2021-02-26)
12
+
13
+ - Fix compatibility with graphql-ruby 1.12.4 ([@haines][])
14
+
5
15
  ## 0.5.2 (2020-10-20)
6
16
 
7
17
  - Fix modules reloading in development. ([@rzaharenkov][])
@@ -76,3 +86,4 @@ Action Policy helpers there.
76
86
  [@haines]: https://github.com/haines
77
87
  [@sponomarev]: https://github.com/sponomarev
78
88
  [@bibendi]: https://github.com/bibendi
89
+ [@rzaharenkov]: https://github.com/rzaharenkov
data/README.md CHANGED
@@ -5,6 +5,9 @@
5
5
 
6
6
  # Action Policy GraphQL
7
7
 
8
+ <img align="right" height="150" width="129"
9
+ title="Action Policy logo" src="./assets/logo.svg">
10
+
8
11
  This gem provides an integration for using [Action Policy](https://github.com/palkan/action_policy) as an authorization framework for GraphQL applications (built with [`graphql` ruby gem](https://graphql-ruby.org)).
9
12
 
10
13
  This integration includes the following features:
@@ -14,6 +14,10 @@ module ActionPolicy
14
14
  # end
15
15
  module AuthorizedField
16
16
  class Extension < ::GraphQL::Schema::FieldExtension
17
+ def initialize(field:, options:)
18
+ super(field: field, options: options&.dup || {})
19
+ end
20
+
17
21
  def extract_option(key, &default)
18
22
  value = options.fetch(key, &default)
19
23
  options.delete key
@@ -39,7 +43,7 @@ module ActionPolicy
39
43
  end
40
44
 
41
45
  def apply
42
- self.class.show_authorize_mutation_deprecation if field.mutation
46
+ self.class.show_authorize_mutation_deprecation if field.mutation && field.mutation < ::GraphQL::Schema::Mutation
43
47
 
44
48
  @to = extract_option(:to) { ::ActionPolicy::GraphQL.default_authorize_rule }
45
49
  @raise = extract_option(:raise) { ::ActionPolicy::GraphQL.authorize_raise_exception }
@@ -114,7 +118,8 @@ module ActionPolicy
114
118
  end
115
119
 
116
120
  class ScopeExtension < Extension
117
- def after_resolve(value:, context:, object:, **_rest)
121
+ def resolve(context:, object:, arguments:, **_rest)
122
+ value = yield(object, arguments)
118
123
  return value if value.nil?
119
124
 
120
125
  object.authorized_scope(value, **options)
@@ -127,7 +132,7 @@ module ActionPolicy
127
132
  "options could be specified. You can use `preauthorize` or `authorize_field` along with scoping"
128
133
  end
129
134
 
130
- if !!authorize == !!preauthorize ? authorize : authorize_field
135
+ if (!!authorize == !!preauthorize) ? authorize : authorize_field
131
136
  raise ArgumentError, "Only one of `authorize`, `preauthorize` or `authorize_field` " \
132
137
  "options could be specified."
133
138
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActionPolicy
4
4
  module GraphQL
5
- VERSION = "0.5.2"
5
+ VERSION = "0.5.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_policy-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2023-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: action_policy
@@ -70,28 +70,28 @@ dependencies:
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.8'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.8'
97
97
  - !ruby/object:Gem::Dependency
@@ -135,7 +135,7 @@ metadata:
135
135
  documentation_uri: https://actionpolicy.evilmartians.io/#/graphql
136
136
  homepage_uri: https://github.com/palkan/action_policy-graphql
137
137
  source_code_uri: https://github.com/palkan/action_policy-graphql
138
- post_install_message:
138
+ post_install_message:
139
139
  rdoc_options: []
140
140
  require_paths:
141
141
  - lib
@@ -150,8 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  requirements: []
153
- rubygems_version: 3.0.6
154
- signing_key:
153
+ rubygems_version: 3.4.20
154
+ signing_key:
155
155
  specification_version: 4
156
156
  summary: Action Policy integration for GraphQL-Ruby
157
157
  test_files: []