graphql-pundit-387 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'graphql-pundit/common'
4
+
5
+ module GraphQL
6
+ module Pundit
7
+ # Scope methods to be included in the used Field class
8
+ module Scope
9
+ def self.prepended(base)
10
+ base.include(GraphQL::Pundit::Common)
11
+ end
12
+
13
+ def initialize(*args, before_scope: nil,
14
+ after_scope: nil,
15
+ **kwargs, &block)
16
+ @before_scope = before_scope
17
+ @after_scope = after_scope
18
+ super(*args, **kwargs, &block)
19
+ end
20
+
21
+ def before_scope(scope = true)
22
+ @before_scope = scope
23
+ end
24
+
25
+ def after_scope(scope = true)
26
+ @after_scope = scope
27
+ end
28
+
29
+ def resolve_field(obj, args, ctx)
30
+ before_scope_return = apply_scope(@before_scope, obj, args, ctx)
31
+ field_return = super(before_scope_return, args, ctx)
32
+ apply_scope(@after_scope, field_return, args, ctx)
33
+ end
34
+
35
+ private
36
+
37
+ def apply_scope(scope, root, arguments, context)
38
+ return root unless scope
39
+ return scope.call(root, arguments, context) if scope.respond_to?(:call)
40
+
41
+ scope = infer_scope(root) if scope.equal?(true)
42
+ scope::Scope.new(context[self.class.current_user], root).resolve
43
+ end
44
+
45
+ def infer_scope(root)
46
+ infer_from = model?(root) ? root.model : root
47
+ ::Pundit::PolicyFinder.new(infer_from).policy!
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphQL
4
+ module Pundit
5
+ VERSION = '0.7.1'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,258 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphql-pundit-387
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.1
5
+ platform: ruby
6
+ authors:
7
+ - Ontohub Core Developers
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: graphql
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.4
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 1.10.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.6.4
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 1.10.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: pundit
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 1.1.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 1.1.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.14'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.14'
61
+ - !ruby/object:Gem::Dependency
62
+ name: codecov
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.1.10
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.1.10
75
+ - !ruby/object:Gem::Dependency
76
+ name: fuubar
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 2.3.0
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 2.3.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: pry
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.11.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.11.0
103
+ - !ruby/object:Gem::Dependency
104
+ name: pry-byebug
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 3.6.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 3.6.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: pry-rescue
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 1.4.4
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 1.4.4
131
+ - !ruby/object:Gem::Dependency
132
+ name: pry-stack_explorer
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 0.4.9.2
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 0.4.9.2
145
+ - !ruby/object:Gem::Dependency
146
+ name: rake
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '12.0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '12.0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: rspec
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '3.6'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '3.6'
173
+ - !ruby/object:Gem::Dependency
174
+ name: rubocop
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: 0.57.0
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: 0.57.0
187
+ - !ruby/object:Gem::Dependency
188
+ name: simplecov
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: 0.16.1
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: 0.16.1
201
+ description: Pundit authorization support for graphql
202
+ email:
203
+ - ontohub-dev-l@ovgu.de
204
+ executables: []
205
+ extensions: []
206
+ extra_rdoc_files: []
207
+ files:
208
+ - ".codeclimate.yml"
209
+ - ".gitignore"
210
+ - ".hound.yml"
211
+ - ".rspec"
212
+ - ".rubocop.yml"
213
+ - ".ruby-version"
214
+ - ".stickler.yml"
215
+ - ".travis.yml"
216
+ - Gemfile
217
+ - LICENSE.txt
218
+ - README.md
219
+ - Rakefile
220
+ - bin/console
221
+ - bin/setup
222
+ - graphql-pundit.gemspec
223
+ - lib/graphql-pundit.rb
224
+ - lib/graphql-pundit/authorization.rb
225
+ - lib/graphql-pundit/common.rb
226
+ - lib/graphql-pundit/field.rb
227
+ - lib/graphql-pundit/instrumenter.rb
228
+ - lib/graphql-pundit/instrumenters/after_scope.rb
229
+ - lib/graphql-pundit/instrumenters/authorization.rb
230
+ - lib/graphql-pundit/instrumenters/before_scope.rb
231
+ - lib/graphql-pundit/instrumenters/scope.rb
232
+ - lib/graphql-pundit/scope.rb
233
+ - lib/graphql-pundit/version.rb
234
+ homepage: https://github.com/ontohub/graphql-pundit
235
+ licenses:
236
+ - MIT
237
+ metadata: {}
238
+ post_install_message:
239
+ rdoc_options: []
240
+ require_paths:
241
+ - lib
242
+ required_ruby_version: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ required_rubygems_version: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - ">="
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ requirements: []
253
+ rubyforge_project:
254
+ rubygems_version: 2.7.7
255
+ signing_key:
256
+ specification_version: 4
257
+ summary: Pundit authorization support for graphql
258
+ test_files: []