rack-graphql 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 535af6fb2ace2236a1f0a4e9b9bebc2d7994faba89c00d360c2766df2b9ef6bf
4
- data.tar.gz: ca6da432ed43fcd68aaaa5063dbd525ae47ef74bd4fd7ff489265475b9c1ec0f
3
+ metadata.gz: 89001cf0e27af277a4e74c423e6ebaed600057a5528d9c0b850a76f704690454
4
+ data.tar.gz: d5250dddf85e2203701d5357f6479001294e64f7d3f28457bc10b55698e0f0c7
5
5
  SHA512:
6
- metadata.gz: 392778718046028d89a8a4ad817b8894100e556c337730681f7391b177d098144d7086971df9333607db846f482344fea6d663de782ff1fadb36c85851250e34
7
- data.tar.gz: 26fa315ff80b03f38be308280245e1e90d92808a431062eeb72fd04d92d7c2d0d44c31c6dc27111f39251d6f67e57f6159a7603b8df33a09efad2b0025c71b07
6
+ metadata.gz: e0975735f7f595af62aeece22cb537e454eef1608b0f012af59e0cc65e14b3015c1db2dd9b7e15402b19bbf1cf564e9982bcd8c79c22681e486d23ae2a96be25
7
+ data.tar.gz: 508d6a5276bfbc8914c9870e4cfa390455ef687634f7de4fc314f28f2c19feedcf7f78de7a39add4543947a44e08e1b0e2de978a1598ac3e8369e5c921c12140
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.1.0 - 2020-09-14
4
+
5
+ - Add `log_exception_backtrace` option to `RackGraphql::Application`
6
+
3
7
  ## 2.0.0 - 2020-09-14
4
8
 
5
9
  - Catch all exceptions raised by the app respond with 500 status codea and json content type
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-graphql (2.0.0)
4
+ rack-graphql (2.1.0)
5
5
  graphql (~> 1.11)
6
6
  oj
7
7
  rack (~> 2.2)
data/README.md CHANGED
@@ -23,11 +23,12 @@ Add following to your `config.ru` file:
23
23
 
24
24
  ```ruby
25
25
  run RackGraphql::Application.call(
26
- schema: YourGraqphqlSchema, # required
27
- app_name: 'your-service-name', # optional, used for health endpoint content
28
- context_handler: YourGraphqlContextHandler, # optional, empty `proc` by default
29
- health_route: true, # optional, true by default
30
- logger: A9n.logger, # optional, not set by default
26
+ schema: YourGraqphqlSchema, # required
27
+ app_name: 'your-service-name', # optional, used for health endpoint content
28
+ context_handler: YourGraphqlContextHandler, # optional, empty `proc` by default
29
+ log_exception_backtrace: !A9n.env.production?, # optional, `true` default
30
+ health_route: true, # optional, true by default
31
+ logger: A9n.logger, # optional, not set by default
31
32
  )
32
33
  ```
33
34
 
@@ -1,11 +1,18 @@
1
1
  module RackGraphql
2
2
  class Application
3
- def self.call(schema:, app_name: 'rack-graphql-service', logger: nil, context_handler: nil,
4
- health_route: true, health_response_builder: RackGraphql::HealthResponseBuilder)
3
+ def self.call(
4
+ schema:,
5
+ app_name: 'rack-graphql-service',
6
+ logger: nil,
7
+ context_handler: nil,
8
+ log_exception_backtrace: RackGraphql.log_exception_backtrace,
9
+ health_route: true,
10
+ health_response_builder: RackGraphql::HealthResponseBuilder
11
+ )
5
12
 
6
13
  ::Rack::Builder.new do
7
14
  map '/graphql' do
8
- run RackGraphql::Middleware.new(schema: schema, context_handler: context_handler, logger: logger)
15
+ run RackGraphql::Middleware.new(schema: schema, context_handler: context_handler, log_exception_backtrace: log_exception_backtrace, logger: logger)
9
16
  end
10
17
 
11
18
  if health_route
@@ -1,9 +1,10 @@
1
1
  module RackGraphql
2
2
  class Middleware
3
- def initialize(schema:, logger: nil, context_handler: nil)
3
+ def initialize(schema:, logger: nil, context_handler: nil, log_exception_backtrace: RackGraphql.log_exception_backtrace)
4
4
  @schema = schema
5
5
  @logger = logger
6
6
  @context_handler = context_handler || ->(_) {}
7
+ @log_exception_backtrace = log_exception_backtrace
7
8
  end
8
9
 
9
10
  def call(env)
@@ -53,7 +54,7 @@ module RackGraphql
53
54
 
54
55
  private
55
56
 
56
- attr_reader :schema, :logger, :context_handler
57
+ attr_reader :schema, :logger, :context_handler, :log_exception_backtrace
57
58
 
58
59
  def post_request?(env)
59
60
  env['REQUEST_METHOD'] == 'POST'
@@ -151,14 +152,14 @@ module RackGraphql
151
152
  # Based on https://github.com/rack/rack/blob/master/lib/rack/show_exceptions.rb
152
153
  def dump_exception(exception)
153
154
  string = "#{exception.class}: #{exception.message}\n"
154
- string << exception.backtrace.map { |l| "\t#{l}" }.join("\n") if RackGraphql.log_exception_backtrace
155
+ string << exception.backtrace.map { |l| "\t#{l}" }.join("\n") if log_exception_backtrace
155
156
  string
156
157
  end
157
158
 
158
159
  def exception_hash(exception)
159
160
  {
160
161
  message: "#{exception.class}: #{exception.message}",
161
- backtrace: RackGraphql.log_exception_backtrace ? exception.backtrace : "[FILTERED]"
162
+ backtrace: log_exception_backtrace ? exception.backtrace : "[FILTERED]"
162
163
  }
163
164
  end
164
165
  end
@@ -1,3 +1,3 @@
1
1
  module RackGraphql
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
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: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik