rack-graphql 2.6.0 → 2.7.2

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: 845b505da7e26dbe5a9e5065514f0420de0c0394f09692afb6d49a134a35dcc2
4
- data.tar.gz: 570b9ce45188d4371f18dd371468f77341535e54f574e06cc184e4e2aaf97adc
3
+ metadata.gz: ad85b5153fed695fa5a81a301fe3333490bdb8ab4064ea5068d51d1915007267
4
+ data.tar.gz: c8b8ba9d4e0e23d3c629bf7d6414e6c7208750b75ae9ac2056f669f46afacfdd
5
5
  SHA512:
6
- metadata.gz: cbc0bbdad9edd52702b4bf7ad70dc46cf592a39e5a47fdb4031f87d1fcb29ca846555a8e05fa0e9620eb198f30212a17169444c6fe53be0a7083941bb8563a83
7
- data.tar.gz: 11e95a8121612f0cd206cea8ac3109e02c5cc30a24524b1032b9d378926e0314a8c474b49e6c494a26d489e14f1e444b240c1f61ee330d5784d1d7c29639846e
6
+ metadata.gz: 6facfa29cc5605ec94a876b1c2085a1c9c701e851e38d1d4a99fcf7e621814471763e82b1793d4670c7c4d7b05e2559b8a846a211054a6323804111f7b63dd24
7
+ data.tar.gz: 3e4a84e3752823947acf281d02544bdff29878e580f3441f7f391e65f578bdc92cc2b146535301163fdb2862f5b6a1cb169258041e3ad189c261adfa4b22d141
data/.bundler-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.5
@@ -3,9 +3,14 @@ version: 1
3
3
  update_configs:
4
4
  - package_manager: "ruby:bundler"
5
5
  directory: "/"
6
- update_schedule: "monthly"
6
+ update_schedule: "daily"
7
7
  commit_message:
8
8
  prefix: "[dependabot]"
9
9
  allowed_updates:
10
10
  - match:
11
- update_type: "all"
11
+ dependency_type: "all"
12
+ update_type: "security"
13
+ automerged_updates:
14
+ - match:
15
+ dependency_type: "all"
16
+ update_type: "security:patch"
@@ -1,18 +1,6 @@
1
- ## Description
1
+ ## Description, motivation and context
2
2
  <!--- Describe your changes in detail -->
3
-
4
- ## Related issue(s)
5
- <!--- GH issue number -->
6
-
7
- ## Motivation and Context
8
3
  <!--- Why is this change required? What problem does it solve? -->
9
- <!--- If it fixes an open issue, please link to the issue here. -->
10
4
 
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). -->
5
+ ## Related issue(s) or PR(s)
6
+ <!--- GH issue number -->
@@ -10,7 +10,7 @@ jobs:
10
10
  auto-approve:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: hmarr/auto-approve-action@v2.0.0
13
+ - uses: hmarr/auto-approve-action@v2
14
14
  if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' || github.actor == 'renofidev'
15
15
  with:
16
16
  github-token: "${{ secrets.GITHUB_TOKEN }}"
@@ -0,0 +1,28 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['3.0']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby
19
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
20
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
21
+ # uses: ruby/setup-ruby@v1
22
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
26
+
27
+ - name: Run tests
28
+ run: bundle exec rake ci
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.7.0 - 2021-03-24
4
+
5
+ - Add ability to skip setting up health endpoint on root path with `health_on_root_path` option.
6
+
7
+ ## 2.6.1 - 2021-01-14
8
+
9
+ - Fix uninitialized `Timeout` error. The issue was fixed in https://github.com/rmosolgo/graphql-ruby/commit/56abba472dbb48a1f8445d41f928bea72b5148e9, but new version has not yet been relased.
10
+
3
11
  ## 2.6.0 - 2021-01-14
4
12
 
5
13
  - Add ability to re-raise exception (`re_raise_exceptions` option)
data/Gemfile.lock CHANGED
@@ -1,34 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-graphql (2.6.0)
5
- graphql (~> 1.11)
4
+ rack-graphql (2.7.2)
5
+ graphql (~> 1.12)
6
6
  oj
7
7
  rack (~> 2.2)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- ast (2.4.1)
13
- awesome_print (1.8.0)
12
+ ast (2.4.2)
13
+ awesome_print (1.9.2)
14
14
  coderay (1.1.3)
15
- diff-lcs (1.4.4)
16
- graphql (1.11.6)
15
+ diff-lcs (1.5.0)
16
+ graphql (1.13.4)
17
17
  method_source (1.0.0)
18
- oj (3.11.0)
19
- parallel (1.20.1)
20
- parser (3.0.0.0)
18
+ oj (3.13.11)
19
+ parallel (1.21.0)
20
+ parser (3.1.0.0)
21
21
  ast (~> 2.4.1)
22
- pry (0.13.1)
22
+ pry (0.14.1)
23
23
  coderay (~> 1.1)
24
24
  method_source (~> 1.0)
25
25
  rack (2.2.3)
26
26
  rack-test (1.1.0)
27
27
  rack (>= 1.0, < 3)
28
- rainbow (3.0.0)
29
- rake (13.0.3)
30
- regexp_parser (2.0.3)
31
- rexml (3.2.4)
28
+ rainbow (3.1.1)
29
+ rake (13.0.6)
30
+ regexp_parser (2.2.0)
31
+ rexml (3.2.5)
32
32
  rspec (3.10.0)
33
33
  rspec-core (~> 3.10.0)
34
34
  rspec-expectations (~> 3.10.0)
@@ -38,31 +38,34 @@ GEM
38
38
  rspec-expectations (3.10.1)
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
40
  rspec-support (~> 3.10.0)
41
- rspec-mocks (3.10.1)
41
+ rspec-mocks (3.10.2)
42
42
  diff-lcs (>= 1.2.0, < 2.0)
43
43
  rspec-support (~> 3.10.0)
44
- rspec-support (3.10.1)
45
- rubocop (1.8.0)
44
+ rspec-support (3.10.3)
45
+ rubocop (1.24.1)
46
46
  parallel (~> 1.10)
47
47
  parser (>= 3.0.0.0)
48
48
  rainbow (>= 2.2.2, < 4.0)
49
49
  regexp_parser (>= 1.8, < 3.0)
50
50
  rexml
51
- rubocop-ast (>= 1.2.0, < 2.0)
51
+ rubocop-ast (>= 1.15.1, < 2.0)
52
52
  ruby-progressbar (~> 1.7)
53
53
  unicode-display_width (>= 1.4.0, < 3.0)
54
- rubocop-ast (1.4.0)
55
- parser (>= 2.7.1.5)
56
- rubocop-rake (0.5.1)
57
- rubocop
58
- rubocop-rspec (2.1.0)
54
+ rubocop-ast (1.15.1)
55
+ parser (>= 3.0.1.1)
56
+ rubocop-rake (0.6.0)
59
57
  rubocop (~> 1.0)
60
- rubocop-ast (>= 1.1.0)
58
+ rubocop-rspec (2.7.0)
59
+ rubocop (~> 1.19)
61
60
  ruby-progressbar (1.11.0)
62
- unicode-display_width (2.0.0)
61
+ unicode-display_width (2.1.0)
63
62
 
64
63
  PLATFORMS
65
- ruby
64
+ aarch64-linux-musl
65
+ x86_64-darwin-18
66
+ x86_64-darwin-19
67
+ x86_64-darwin-20
68
+ x86_64-darwin-21
66
69
  x86_64-linux
67
70
 
68
71
  DEPENDENCIES
@@ -78,4 +81,4 @@ DEPENDENCIES
78
81
  rubocop-rspec
79
82
 
80
83
  BUNDLED WITH
81
- 2.2.4
84
+ 2.3.5
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rack-graphql.svg)](https://rubygems.org/gems/rack-graphql)
2
- [![Build Status](https://travis-ci.org/RenoFi/rack-graphql.svg?branch=master)](https://travis-ci.org/RenoFi/rack-graphql)
2
+ [![Build Status](https://github.com/RenoFi/rack-graphql/actions/workflows/ci.yml/badge.svg)](https://github.com/RenoFi/rack-graphql/actions/workflows/ci.yml?query=branch%3Amain)
3
3
 
4
4
  # rack-graphql
5
5
 
@@ -29,6 +29,7 @@ run RackGraphql::Application.call(
29
29
  log_exception_backtrace: !A9n.env.production?, # optional, `false` default
30
30
  # `true` when `RACK_GRAPHQL_LOG_EXCEPTION_BACKTRACE` env var is set to `'1'` or `'true'`
31
31
  health_route: true, # optional, true by default
32
+ health_on_root_path: health_route, # optional, health_route value by default (mind map '/' is covering '/any/path-123')
32
33
  logger: A9n.logger, # optional, not set by default
33
34
  error_status_code_map: { IamTeapotError => 418 }, # optional
34
35
  re_raise_exceptions: true, # optional, false by default
@@ -87,32 +88,31 @@ RackGraphql.log_exception_backtrace = false
87
88
  To respect the graphql spec, all errors need to be returned as json and `rack-graphql` catches all exceptions and does NOT re-raise them. You can change this behavior via `re_raise_exceptions` argument.
88
89
  Because of this, using error tracking middleware (`use Sentry::Rack::CaptureExceptions`, `use Raven::Rack`) does not take any effect for graphql requests.
89
90
 
90
- To use Sentry or other reporting tool for graphql queries, you can use `GraphQL::Schema` middleware:
91
+ To use Sentry or other reporting tool for graphql queries, you should handle it on graphql schema level:
91
92
 
92
93
  ```ruby
93
- class GraphqlErrorTrackerMiddleware
94
- def self.call(parent_type, parent_object, field_definition, field_args, query_context)
95
- yield
96
- rescue StandardError => e
94
+ class MySchema < GraphQL::Schema
95
+ rescue_from StandardError do |e, obj, args, ctx, field|
97
96
  extra = {
98
- parent_type: parent_type.inspect,
99
- parent_object: parent_object.inspect,
100
- field_definition: field_definition.to_s,
101
- field_args: field_args&.to_h,
102
- query_context: query_context&.to_h
97
+ args: args,
98
+ field: field.inspect,
99
+ context: ctx
103
100
  }
104
101
  Sentry.capture_exception(e, extra: extra)
102
+ # re-raise to be handled by rack middleware
105
103
  raise
104
+ # or return execution error
105
+ ::GraphQL::ExecutionError.new(
106
+ exception.class.to_s,
107
+ options: { "http_status" => 500 },
108
+ extensions: {
109
+ "code" => exception.class.to_s,
110
+ "http_status" => 500,
111
+ "details" => exception.inspect
112
+ }
113
+ )
106
114
  end
107
115
  end
108
-
109
- # MySchema.middleware GraphqlErrorTrackerMiddleware
110
- # or
111
- # GraphQL::Schema.middleware GraphqlErrorTrackerMiddleware
112
- # or
113
- # class MySchema < GraphQL::Schema
114
- # middleware GraphqlErrorTrackerMiddleware
115
- # end
116
116
  ```
117
117
 
118
118
  ## Contributing
data/Rakefile CHANGED
@@ -5,4 +5,5 @@ require 'rubocop/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
  RuboCop::RakeTask.new
7
7
 
8
+ task ci: %i[spec rubocop]
8
9
  task default: %i[spec rubocop:auto_correct]
@@ -9,6 +9,7 @@ module RackGraphql
9
9
  log_exception_backtrace: RackGraphql.log_exception_backtrace,
10
10
  health_route: true,
11
11
  health_response_builder: RackGraphql::HealthResponseBuilder,
12
+ health_on_root_path: health_route,
12
13
  error_status_code_map: {}
13
14
  )
14
15
 
@@ -33,7 +34,9 @@ module RackGraphql
33
34
  map '/healthz' do
34
35
  run ->(env) { health_response_builder.new(app_name: app_name, env: env).build }
35
36
  end
37
+ end
36
38
 
39
+ if health_on_root_path
37
40
  map '/' do
38
41
  run ->(env) { health_response_builder.new(app_name: app_name, env: env).build }
39
42
  end
@@ -70,7 +70,10 @@ module RackGraphql
70
70
  [Oj.dump('errors' => [exception_hash(e)])]
71
71
  ]
72
72
  ensure
73
- ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
73
+ if defined?(ActiveRecord::Base)
74
+ ActiveRecord::Base.clear_active_connections!
75
+ ActiveRecord::Base.flush_idle_connections!
76
+ end
74
77
  end
75
78
 
76
79
  private
@@ -178,6 +181,7 @@ module RackGraphql
178
181
 
179
182
  def log(message)
180
183
  return unless logger
184
+
181
185
  logger.debug("[rack-graphql] #{message}")
182
186
  end
183
187
 
@@ -1,3 +1,3 @@
1
1
  module RackGraphql
2
- VERSION = '2.6.0'.freeze
2
+ VERSION = '2.7.2'.freeze
3
3
  end
data/lib/rack_graphql.rb CHANGED
@@ -2,6 +2,10 @@ require 'oj'
2
2
  require 'rack'
3
3
  require 'graphql'
4
4
 
5
+ # Timeout needs to be manually required before following fix is released:
6
+ # https://github.com/rmosolgo/graphql-ruby/commit/56abba472dbb48a1f8445d41f928bea72b5148e9
7
+ require 'timeout'
8
+
5
9
  require 'rack_graphql/version'
6
10
  require 'rack_graphql/exceptions'
7
11
  require 'rack_graphql/health_response_builder'
data/rack-graphql.gemspec CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.metadata['homepage_uri'] = 'https://github.com/RenoFi/rack-graphql'
16
16
  spec.metadata['source_code_uri'] = 'https://github.com/RenoFi/rack-graphql'
17
17
  spec.metadata['changelog_uri'] = 'https://github.com/RenoFi/rack-graphql/blob/master/CHANGELOG.md'
18
+ spec.metadata['rubygems_mfa_required'] = 'true'
18
19
 
19
20
  spec.files = Dir.chdir(__dir__) do
20
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin/|spec/|\.rub)}) }
@@ -25,7 +26,7 @@ Gem::Specification.new do |spec|
25
26
 
26
27
  spec.required_ruby_version = '>= 2.6'
27
28
 
28
- spec.add_dependency 'graphql', '~> 1.11'
29
+ spec.add_dependency 'graphql', '~> 1.12'
29
30
  spec.add_dependency 'oj'
30
31
  spec.add_dependency 'rack', '~> 2.2'
31
32
 
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.6.0
4
+ version: 2.7.2
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: 2021-01-14 00:00:00.000000000 Z
12
+ date: 2022-01-13 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.11'
20
+ version: '1.12'
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.11'
27
+ version: '1.12'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: oj
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +187,7 @@ executables: []
187
187
  extensions: []
188
188
  extra_rdoc_files: []
189
189
  files:
190
+ - ".bundler-version"
190
191
  - ".dependabot/config.yml"
191
192
  - ".github/ISSUE_TEMPLATE/bug_report.md"
192
193
  - ".github/ISSUE_TEMPLATE/config.yml"
@@ -194,9 +195,9 @@ files:
194
195
  - ".github/PULL_REQUEST_TEMPLATE.md"
195
196
  - ".github/workflows/auto-approve.yml"
196
197
  - ".github/workflows/auto-merge.yml"
198
+ - ".github/workflows/ci.yml"
197
199
  - ".gitignore"
198
200
  - ".rspec"
199
- - ".travis.yml"
200
201
  - CHANGELOG.md
201
202
  - Gemfile
202
203
  - Gemfile.lock
@@ -218,6 +219,7 @@ metadata:
218
219
  homepage_uri: https://github.com/RenoFi/rack-graphql
219
220
  source_code_uri: https://github.com/RenoFi/rack-graphql
220
221
  changelog_uri: https://github.com/RenoFi/rack-graphql/blob/master/CHANGELOG.md
222
+ rubygems_mfa_required: 'true'
221
223
  post_install_message:
222
224
  rdoc_options: []
223
225
  require_paths:
@@ -233,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
235
  - !ruby/object:Gem::Version
234
236
  version: '0'
235
237
  requirements: []
236
- rubygems_version: 3.2.3
238
+ rubygems_version: 3.2.32
237
239
  signing_key:
238
240
  specification_version: 4
239
241
  summary: Rack middleware implementing graphql endpoint.
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6
7
- - 2.7
8
- - 3.0
9
- before_install: gem install bundler
10
- script:
11
- - bundle exec rake rubocop
12
- - bundle exec rake spec