rack-graphql 1.2.5 → 2.0.0.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/auto-approve.yml +3 -3
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +4 -4
- data/README.md +9 -0
- data/lib/rack_graphql.rb +8 -0
- data/lib/rack_graphql/middleware.rb +33 -3
- data/lib/rack_graphql/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1075eb9d4a87a4e94b555c8b7f60a6a36c8369b2ff0d60a8e7be9db675f47494
|
4
|
+
data.tar.gz: ae1137154106d644ee012734ed0d5d21ac11412fb55a4ba12394bdc26e57b873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eeb4e9eed9cf0030651c30d6ef16bb53f14ece2cf2f94c36f162d13d3732fe53e699e64b59d2d807b2d64386453d21627f3f718a50db99e10ab74f1fa2c9c20
|
7
|
+
data.tar.gz: efe2f531123d657e2480a08f4d0b898d9cda4fea50bbe9422faaeb4fc0d4d3ddec13c93c54c4aae5a9792d7bece88652cb35bdeca82bfdbdf315f6c9df724427
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# automatically approve PRs submitted by Dependabot
|
1
|
+
# automatically approve PRs submitted by Dependabot or Renofidev
|
2
2
|
# this will allow Dependabot to automatically merge dependency update PRs where CI passes
|
3
3
|
# from: https://github.com/hmarr/auto-approve-action
|
4
|
-
name: Auto approve
|
4
|
+
name: Auto approve dependency upgrades PRs
|
5
5
|
|
6
6
|
on:
|
7
7
|
pull_request
|
@@ -11,6 +11,6 @@ jobs:
|
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
steps:
|
13
13
|
- uses: hmarr/auto-approve-action@v2.0.0
|
14
|
-
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
|
14
|
+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || github.actor == 'renofidev'
|
15
15
|
with:
|
16
16
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-graphql (
|
4
|
+
rack-graphql (2.0.0.rc)
|
5
5
|
graphql (~> 1.9)
|
6
6
|
oj
|
7
7
|
rack (~> 2.0)
|
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
diff-lcs (1.4.4)
|
15
15
|
graphql (1.11.4)
|
16
16
|
method_source (1.0.0)
|
17
|
-
oj (3.10.
|
17
|
+
oj (3.10.14)
|
18
18
|
parallel (1.19.2)
|
19
19
|
parser (2.7.1.4)
|
20
20
|
ast (~> 2.4.1)
|
@@ -52,8 +52,8 @@ GEM
|
|
52
52
|
unicode-display_width (>= 1.4.0, < 2.0)
|
53
53
|
rubocop-ast (0.3.0)
|
54
54
|
parser (>= 2.7.1.4)
|
55
|
-
rubocop-performance (1.
|
56
|
-
rubocop (>= 0.
|
55
|
+
rubocop-performance (1.8.0)
|
56
|
+
rubocop (>= 0.87.0)
|
57
57
|
rubocop-rspec (1.43.2)
|
58
58
|
rubocop (~> 0.87)
|
59
59
|
ruby-progressbar (1.10.1)
|
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: [{ message: exception_string }])]
|
49
|
+
]
|
27
50
|
ensure
|
28
51
|
ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
|
29
52
|
end
|
@@ -124,5 +147,12 @@ 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
|
127
157
|
end
|
128
158
|
end
|
data/lib/rack_graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Knapik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-09-
|
12
|
+
date: 2020-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- ".gitignore"
|
183
183
|
- ".rspec"
|
184
184
|
- ".travis.yml"
|
185
|
+
- CHANGELOG.md
|
185
186
|
- Gemfile
|
186
187
|
- Gemfile.lock
|
187
188
|
- LICENSE
|
@@ -212,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
213
|
version: '2.6'
|
213
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
215
|
requirements:
|
215
|
-
- - "
|
216
|
+
- - ">"
|
216
217
|
- !ruby/object:Gem::Version
|
217
|
-
version:
|
218
|
+
version: 1.3.1
|
218
219
|
requirements: []
|
219
220
|
rubygems_version: 3.1.2
|
220
221
|
signing_key:
|