rack-graphql 1.2.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dependabot/config.yml +0 -7
- data/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- data/.github/ISSUE_TEMPLATE/config.yml +1 -0
- data/.github/ISSUE_TEMPLATE/story.md +22 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +18 -0
- data/.github/workflows/auto-approve.yml +16 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +28 -25
- data/README.md +9 -0
- data/lib/rack_graphql.rb +8 -0
- data/lib/rack_graphql/middleware.rb +41 -4
- data/lib/rack_graphql/version.rb +1 -1
- data/rack-graphql.gemspec +2 -2
- metadata +16 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 535af6fb2ace2236a1f0a4e9b9bebc2d7994faba89c00d360c2766df2b9ef6bf
|
4
|
+
data.tar.gz: ca6da432ed43fcd68aaaa5063dbd525ae47ef74bd4fd7ff489265475b9c1ec0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 392778718046028d89a8a4ad817b8894100e556c337730681f7391b177d098144d7086971df9333607db846f482344fea6d663de782ff1fadb36c85851250e34
|
7
|
+
data.tar.gz: 26fa315ff80b03f38be308280245e1e90d92808a431062eeb72fd04d92d7c2d0d44c31c6dc27111f39251d6f67e57f6159a7603b8df33a09efad2b0025c71b07
|
data/.dependabot/config.yml
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to track an issue that has been identified
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the bug**
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
**To Reproduce**
|
14
|
+
Steps to reproduce the behavior:
|
15
|
+
1. Go to '...'
|
16
|
+
2. Click on '....'
|
17
|
+
3. Scroll down to '....'
|
18
|
+
4. See error
|
19
|
+
|
20
|
+
**Expected behavior**
|
21
|
+
A clear and concise description of what you expected to happen.
|
22
|
+
|
23
|
+
**Mutation/Query**
|
24
|
+
|
25
|
+
**URL and HTTP method (for non-GQL):**
|
26
|
+
|
27
|
+
**Sentry or Logs URL:**
|
28
|
+
|
29
|
+
**User/authentication details**
|
30
|
+
Impacted user name or service account
|
31
|
+
|
32
|
+
**Additional context**
|
33
|
+
Add any other context about the problem here.
|
@@ -0,0 +1 @@
|
|
1
|
+
blank_issues_enabled: false
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
name: New story
|
3
|
+
about: Add a new story for implementation
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the solution**
|
11
|
+
A clear and concise description of what you want to happen.
|
12
|
+
When will this feature be done?
|
13
|
+
|
14
|
+
**Describe the users**
|
15
|
+
Who are we building this feature for?
|
16
|
+
|
17
|
+
**Additional context**
|
18
|
+
Add any other context or screenshots about the feature request here.
|
19
|
+
Link to any applicable documents describing the feature.
|
20
|
+
|
21
|
+
**Designs**
|
22
|
+
Link to any applicable designs on Invision.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
## Description
|
2
|
+
<!--- Describe your changes in detail -->
|
3
|
+
|
4
|
+
## Related issue(s)
|
5
|
+
<!--- GH issue number -->
|
6
|
+
|
7
|
+
## Motivation and Context
|
8
|
+
<!--- Why is this change required? What problem does it solve? -->
|
9
|
+
<!--- If it fixes an open issue, please link to the issue here. -->
|
10
|
+
|
11
|
+
## How Has This Been Tested?
|
12
|
+
<!--- Please describe in detail how you tested your changes. -->
|
13
|
+
|
14
|
+
## Screenshots (if appropriate):
|
15
|
+
<!--- Please add any screenshots of the feature. -->
|
16
|
+
|
17
|
+
## Related PRs
|
18
|
+
<!--- Please add links to any related PRs (backend, component packages, etc). -->
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# automatically approve PRs submitted by Dependabot or Renofidev
|
2
|
+
# this will allow Dependabot to automatically merge dependency update PRs where CI passes
|
3
|
+
# from: https://github.com/hmarr/auto-approve-action
|
4
|
+
name: Auto approve dependency upgrades PRs
|
5
|
+
|
6
|
+
on:
|
7
|
+
pull_request
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
auto-approve:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: hmarr/auto-approve-action@v2.0.0
|
14
|
+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || github.actor == 'renofidev'
|
15
|
+
with:
|
16
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,58 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-graphql (
|
5
|
-
graphql (~> 1.
|
4
|
+
rack-graphql (2.0.0)
|
5
|
+
graphql (~> 1.11)
|
6
6
|
oj
|
7
|
-
rack (~> 2.
|
7
|
+
rack (~> 2.2)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
ast (2.4.
|
13
|
-
coderay (1.1.
|
14
|
-
diff-lcs (1.
|
15
|
-
graphql (1.
|
16
|
-
jaro_winkler (1.5.4)
|
12
|
+
ast (2.4.1)
|
13
|
+
coderay (1.1.3)
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
graphql (1.11.4)
|
17
16
|
method_source (1.0.0)
|
18
|
-
oj (3.10.
|
19
|
-
parallel (1.19.
|
20
|
-
parser (2.7.
|
21
|
-
ast (~> 2.4.
|
22
|
-
pry (0.13.
|
17
|
+
oj (3.10.14)
|
18
|
+
parallel (1.19.2)
|
19
|
+
parser (2.7.1.4)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
pry (0.13.1)
|
23
22
|
coderay (~> 1.1)
|
24
23
|
method_source (~> 1.0)
|
25
|
-
rack (2.2.
|
24
|
+
rack (2.2.3)
|
26
25
|
rack-test (1.1.0)
|
27
26
|
rack (>= 1.0, < 3)
|
28
27
|
rainbow (3.0.0)
|
29
28
|
rake (13.0.1)
|
29
|
+
regexp_parser (1.7.1)
|
30
30
|
rexml (3.2.4)
|
31
31
|
rspec (3.9.0)
|
32
32
|
rspec-core (~> 3.9.0)
|
33
33
|
rspec-expectations (~> 3.9.0)
|
34
34
|
rspec-mocks (~> 3.9.0)
|
35
|
-
rspec-core (3.9.
|
36
|
-
rspec-support (~> 3.9.
|
37
|
-
rspec-expectations (3.9.
|
35
|
+
rspec-core (3.9.2)
|
36
|
+
rspec-support (~> 3.9.3)
|
37
|
+
rspec-expectations (3.9.2)
|
38
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
39
|
rspec-support (~> 3.9.0)
|
40
40
|
rspec-mocks (3.9.1)
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
42
|
rspec-support (~> 3.9.0)
|
43
|
-
rspec-support (3.9.
|
44
|
-
rubocop (0.
|
45
|
-
jaro_winkler (~> 1.5.1)
|
43
|
+
rspec-support (3.9.3)
|
44
|
+
rubocop (0.90.0)
|
46
45
|
parallel (~> 1.10)
|
47
|
-
parser (>= 2.7.
|
46
|
+
parser (>= 2.7.1.1)
|
48
47
|
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.7)
|
49
49
|
rexml
|
50
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
50
51
|
ruby-progressbar (~> 1.7)
|
51
52
|
unicode-display_width (>= 1.4.0, < 2.0)
|
52
|
-
rubocop-
|
53
|
-
|
54
|
-
rubocop-
|
55
|
-
rubocop (>= 0.
|
53
|
+
rubocop-ast (0.3.0)
|
54
|
+
parser (>= 2.7.1.4)
|
55
|
+
rubocop-performance (1.8.0)
|
56
|
+
rubocop (>= 0.87.0)
|
57
|
+
rubocop-rspec (1.43.2)
|
58
|
+
rubocop (~> 0.87)
|
56
59
|
ruby-progressbar (1.10.1)
|
57
60
|
unicode-display_width (1.7.0)
|
58
61
|
|
data/README.md
CHANGED
@@ -27,6 +27,7 @@ run RackGraphql::Application.call(
|
|
27
27
|
app_name: 'your-service-name', # optional, used for health endpoint content
|
28
28
|
context_handler: YourGraphqlContextHandler, # optional, empty `proc` by default
|
29
29
|
health_route: true, # optional, true by default
|
30
|
+
logger: A9n.logger, # optional, not set by default
|
30
31
|
)
|
31
32
|
```
|
32
33
|
|
@@ -69,6 +70,14 @@ class GraphqlContextHandler
|
|
69
70
|
end
|
70
71
|
```
|
71
72
|
|
73
|
+
### Logging exception backtrace
|
74
|
+
|
75
|
+
RackGraphql catches all errors and respond with 500 code. By default it adds exception backtrace to the response body. If you don't want to have the backtrace in the response set:
|
76
|
+
|
77
|
+
```
|
78
|
+
RackGraphql.log_exception_backtrace = false
|
79
|
+
```
|
80
|
+
|
72
81
|
## Contributing
|
73
82
|
|
74
83
|
Bug reports and pull requests are welcome on GitHub at https://github.com/RenoFi/rack-graphql. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/lib/rack_graphql.rb
CHANGED
@@ -7,3 +7,11 @@ require 'rack_graphql/exceptions'
|
|
7
7
|
require 'rack_graphql/health_response_builder'
|
8
8
|
require 'rack_graphql/middleware'
|
9
9
|
require 'rack_graphql/application'
|
10
|
+
|
11
|
+
module RackGraphql
|
12
|
+
class << self
|
13
|
+
attr_accessor :log_exception_backtrace
|
14
|
+
end
|
15
|
+
|
16
|
+
self.log_exception_backtrace = true
|
17
|
+
end
|
@@ -20,10 +20,33 @@ module RackGraphql
|
|
20
20
|
log("Executing with params: #{params.inspect}, operationName: #{operation_name}, variables: #{variables.inspect}")
|
21
21
|
result = execute(params: params, operation_name: operation_name, variables: variables, context: context)
|
22
22
|
|
23
|
-
[
|
23
|
+
[
|
24
|
+
200,
|
25
|
+
response_headers(result),
|
26
|
+
[response_body(result)]
|
27
|
+
]
|
24
28
|
rescue AmbiguousParamError => e
|
25
|
-
|
26
|
-
|
29
|
+
exception_string = dump_exception(e)
|
30
|
+
log(exception_string)
|
31
|
+
env[Rack::RACK_ERRORS].puts(exception_string)
|
32
|
+
env[Rack::RACK_ERRORS].flush
|
33
|
+
[
|
34
|
+
400,
|
35
|
+
{ 'Content-Type' => 'application/json' },
|
36
|
+
[Oj.dump({})]
|
37
|
+
]
|
38
|
+
rescue StandardError, LoadError, SyntaxError => e
|
39
|
+
# To respect the graphql spec, all errors need to be returned as json.
|
40
|
+
# It needs to take Rack::ShowExceptions role of catching all exceptions raised by the app.
|
41
|
+
exception_string = dump_exception(e)
|
42
|
+
log(exception_string)
|
43
|
+
env[Rack::RACK_ERRORS].puts(exception_string)
|
44
|
+
env[Rack::RACK_ERRORS].flush
|
45
|
+
[
|
46
|
+
500,
|
47
|
+
{ 'Content-Type' => 'application/json' },
|
48
|
+
[Oj.dump(errors: [exception_hash(e)])]
|
49
|
+
]
|
27
50
|
ensure
|
28
51
|
ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
|
29
52
|
end
|
@@ -37,7 +60,7 @@ module RackGraphql
|
|
37
60
|
end
|
38
61
|
|
39
62
|
def post_data(env)
|
40
|
-
::Oj.load(env['rack.input'].gets)
|
63
|
+
::Oj.load(env['rack.input'].gets.to_s)
|
41
64
|
rescue Oj::ParseError
|
42
65
|
nil
|
43
66
|
end
|
@@ -124,5 +147,19 @@ module RackGraphql
|
|
124
147
|
return unless logger
|
125
148
|
logger.debug("[rack-graphql] #{message}")
|
126
149
|
end
|
150
|
+
|
151
|
+
# Based on https://github.com/rack/rack/blob/master/lib/rack/show_exceptions.rb
|
152
|
+
def dump_exception(exception)
|
153
|
+
string = "#{exception.class}: #{exception.message}\n"
|
154
|
+
string << exception.backtrace.map { |l| "\t#{l}" }.join("\n") if RackGraphql.log_exception_backtrace
|
155
|
+
string
|
156
|
+
end
|
157
|
+
|
158
|
+
def exception_hash(exception)
|
159
|
+
{
|
160
|
+
message: "#{exception.class}: #{exception.message}",
|
161
|
+
backtrace: RackGraphql.log_exception_backtrace ? exception.backtrace : "[FILTERED]"
|
162
|
+
}
|
163
|
+
end
|
127
164
|
end
|
128
165
|
end
|
data/lib/rack_graphql/version.rb
CHANGED
data/rack-graphql.gemspec
CHANGED
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_ruby_version = '>= 2.6'
|
26
26
|
|
27
|
-
spec.add_dependency 'graphql', '~> 1.
|
27
|
+
spec.add_dependency 'graphql', '~> 1.11'
|
28
28
|
spec.add_dependency 'oj'
|
29
|
-
spec.add_dependency 'rack', '~> 2.
|
29
|
+
spec.add_dependency 'rack', '~> 2.2'
|
30
30
|
|
31
31
|
spec.add_development_dependency 'bundler'
|
32
32
|
spec.add_development_dependency 'pry'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Knapik
|
8
8
|
- RenoFi Engineering Team
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.11'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '1.
|
27
|
+
version: '1.11'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: oj
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '2.
|
48
|
+
version: '2.2'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '2.
|
55
|
+
version: '2.2'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
- - ">="
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
|
-
description:
|
168
|
+
description:
|
169
169
|
email:
|
170
170
|
- knapo@knapo.net
|
171
171
|
- engineering@renofi.com
|
@@ -174,9 +174,15 @@ extensions: []
|
|
174
174
|
extra_rdoc_files: []
|
175
175
|
files:
|
176
176
|
- ".dependabot/config.yml"
|
177
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
178
|
+
- ".github/ISSUE_TEMPLATE/config.yml"
|
179
|
+
- ".github/ISSUE_TEMPLATE/story.md"
|
180
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
181
|
+
- ".github/workflows/auto-approve.yml"
|
177
182
|
- ".gitignore"
|
178
183
|
- ".rspec"
|
179
184
|
- ".travis.yml"
|
185
|
+
- CHANGELOG.md
|
180
186
|
- Gemfile
|
181
187
|
- Gemfile.lock
|
182
188
|
- LICENSE
|
@@ -196,7 +202,7 @@ licenses:
|
|
196
202
|
metadata:
|
197
203
|
homepage_uri: https://github.com/RenoFi/rack-graphql
|
198
204
|
source_code_uri: https://github.com/RenoFi/rack-graphql
|
199
|
-
post_install_message:
|
205
|
+
post_install_message:
|
200
206
|
rdoc_options: []
|
201
207
|
require_paths:
|
202
208
|
- lib
|
@@ -212,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
218
|
version: '0'
|
213
219
|
requirements: []
|
214
220
|
rubygems_version: 3.1.2
|
215
|
-
signing_key:
|
221
|
+
signing_key:
|
216
222
|
specification_version: 4
|
217
223
|
summary: Rack middleware implementing graphql endpoint.
|
218
224
|
test_files: []
|