rack-graphql 3.2.0 → 3.3.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: 1dadb267c8ff9335ea2509782e862a43a4baf20e30fd8b98c0106ac69864a21f
4
- data.tar.gz: 0735c228c451e039c3464278f509c792dd28275e165b82ea70d262bd5f3b38f6
3
+ metadata.gz: c5d4ffebb36635210874227b52711af8973b7d882843b19ea29be127bde361e7
4
+ data.tar.gz: ebe79a3fc4bed9259a8d22f915701d9424376866abc082b8c7567afdb1754999
5
5
  SHA512:
6
- metadata.gz: 0040707da5153a109f9d8b5247251a55750006aa92445d2710251015e1420024ac1cbc5fbc6698e87fc2d96f06209737738106b5fb93d2147d9b5c4796ac5911
7
- data.tar.gz: 750abe3e69e19a5e7e6dae568b7dcdddda0d6e85b913308327d03cd7f4cc9e85b7919a5f9193a7fd1a891715c5f27ed2662266aa2c3fb032104aefd5218bda5a
6
+ metadata.gz: ec6cb68ea5a1f5184428a1edee0b9c7349f8cafa14dde3f64ae627d5880506272982b945d77c8c0772ff9a5539dd70689a77aebed80a62825ce4f2dc41fa4fb3
7
+ data.tar.gz: 16e0f39e00e0c1e956c61b4dc353a96f706d264b9d48ba4d297c51732e0fa2b2d28260b0ec4a8b162537fd709203b951c9249fef49432050093d1f58cb16e112
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.3.0 - 2023-11-23
4
+
5
+ - add `request_epilogue` so actions like `ActiveRecord::Base.connection_handler.clear_active_connections!` can be passed manually
6
+ - ruby 3.1 is the minimal ruby version
7
+
3
8
  ## 3.1.3 - 2023-10-10
4
9
 
5
10
  - use `ActiveRecord::Base.connection_handler.clear_active_connections!` instead of ActiveRecord::Base.clear_active_connections!`, which is deprecated
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-graphql (3.2.0)
4
+ rack-graphql (3.3.0)
5
5
  graphql (~> 2.0)
6
6
  oj
7
7
  rack (>= 2.2.6)
@@ -11,10 +11,10 @@ GEM
11
11
  specs:
12
12
  ast (2.4.2)
13
13
  awesome_print (1.9.2)
14
- base64 (0.1.1)
15
14
  coderay (1.1.3)
16
15
  diff-lcs (1.5.0)
17
- graphql (2.1.1)
16
+ graphql (2.1.6)
17
+ racc (~> 1.4)
18
18
  json (2.6.3)
19
19
  language_server-protocol (3.17.0.3)
20
20
  method_source (1.0.0)
@@ -26,13 +26,13 @@ GEM
26
26
  pry (0.14.2)
27
27
  coderay (~> 1.1)
28
28
  method_source (~> 1.0)
29
- racc (1.7.1)
29
+ racc (1.7.3)
30
30
  rack (3.0.8)
31
31
  rack-test (2.1.0)
32
32
  rack (>= 1.3)
33
33
  rainbow (3.1.1)
34
- rake (13.0.6)
35
- regexp_parser (2.8.1)
34
+ rake (13.1.0)
35
+ regexp_parser (2.8.2)
36
36
  rexml (3.2.6)
37
37
  rspec (3.12.0)
38
38
  rspec-core (~> 3.12.0)
@@ -47,19 +47,18 @@ GEM
47
47
  diff-lcs (>= 1.2.0, < 2.0)
48
48
  rspec-support (~> 3.12.0)
49
49
  rspec-support (3.12.1)
50
- rubocop (1.56.4)
51
- base64 (~> 0.1.1)
50
+ rubocop (1.57.2)
52
51
  json (~> 2.3)
53
52
  language_server-protocol (>= 3.17.0)
54
53
  parallel (~> 1.10)
55
- parser (>= 3.2.2.3)
54
+ parser (>= 3.2.2.4)
56
55
  rainbow (>= 2.2.2, < 4.0)
57
56
  regexp_parser (>= 1.8, < 3.0)
58
57
  rexml (>= 3.2.5, < 4.0)
59
58
  rubocop-ast (>= 1.28.1, < 2.0)
60
59
  ruby-progressbar (~> 1.7)
61
60
  unicode-display_width (>= 2.4.0, < 3.0)
62
- rubocop-ast (1.29.0)
61
+ rubocop-ast (1.30.0)
63
62
  parser (>= 3.2.1.0)
64
63
  rubocop-capybara (2.19.0)
65
64
  rubocop (~> 1.41)
@@ -67,8 +66,8 @@ GEM
67
66
  rubocop (~> 1.33)
68
67
  rubocop-rake (0.6.0)
69
68
  rubocop (~> 1.0)
70
- rubocop-rspec (2.24.1)
71
- rubocop (~> 1.33)
69
+ rubocop-rspec (2.25.0)
70
+ rubocop (~> 1.40)
72
71
  rubocop-capybara (~> 2.17)
73
72
  rubocop-factory_bot (~> 2.22)
74
73
  ruby-progressbar (1.13.0)
data/README.md CHANGED
@@ -34,6 +34,7 @@ run RackGraphql::Application.call(
34
34
  logger: A9n.logger, # optional, not set by default
35
35
  error_status_code_map: { IamTeapotError => 418 }, # optional
36
36
  re_raise_exceptions: true, # optional, false by default
37
+ request_epilogue: -> { ActiveRecord::Base.connection_handler.clear_active_connections! }
37
38
  )
38
39
  ```
39
40
 
@@ -11,29 +11,31 @@ module RackGraphql
11
11
  health_response_builder: RackGraphql::HealthResponseBuilder,
12
12
  health_on_root_path: health_route,
13
13
  root_path_app: nil,
14
- error_status_code_map: {}
14
+ error_status_code_map: {},
15
+ request_epilogue: -> {}
15
16
  )
16
17
 
17
18
  ::Rack::Builder.new do
18
19
  map '/graphql' do
19
20
  run RackGraphql::Middleware.new(
20
- app_name: app_name,
21
- schema: schema,
22
- context_handler: context_handler,
23
- re_raise_exceptions: re_raise_exceptions,
24
- logger: logger,
25
- log_exception_backtrace: log_exception_backtrace,
26
- error_status_code_map: error_status_code_map,
21
+ app_name:,
22
+ schema:,
23
+ context_handler:,
24
+ re_raise_exceptions:,
25
+ logger:,
26
+ log_exception_backtrace:,
27
+ error_status_code_map:,
28
+ request_epilogue:,
27
29
  )
28
30
  end
29
31
 
30
32
  if health_route
31
33
  map '/health' do
32
- run ->(env) { health_response_builder.new(app_name: app_name, env: env).build }
34
+ run ->(env) { health_response_builder.new(app_name:, env:).build }
33
35
  end
34
36
 
35
37
  map '/healthz' do
36
- run ->(env) { health_response_builder.new(app_name: app_name, env: env).build }
38
+ run ->(env) { health_response_builder.new(app_name:, env:).build }
37
39
  end
38
40
  end
39
41
 
@@ -43,7 +45,7 @@ module RackGraphql
43
45
  end
44
46
  elsif health_on_root_path
45
47
  map '/' do
46
- run ->(env) { health_response_builder.new(app_name: app_name, env: env).build }
48
+ run ->(env) { health_response_builder.new(app_name:, env:).build }
47
49
  end
48
50
  end
49
51
  end
@@ -13,7 +13,8 @@ module RackGraphql
13
13
  logger: nil,
14
14
  log_exception_backtrace: RackGraphql.log_exception_backtrace,
15
15
  re_raise_exceptions: false,
16
- error_status_code_map: {}
16
+ error_status_code_map: {},
17
+ request_epilogue: -> {}
17
18
  )
18
19
 
19
20
  @schema = schema
@@ -23,6 +24,7 @@ module RackGraphql
23
24
  @log_exception_backtrace = log_exception_backtrace
24
25
  @re_raise_exceptions = re_raise_exceptions
25
26
  @error_status_code_map = error_status_code_map
27
+ @request_epilogue = request_epilogue || -> {}
26
28
  end
27
29
 
28
30
  def call(env)
@@ -37,12 +39,12 @@ module RackGraphql
37
39
  context = context_handler.call(env)
38
40
 
39
41
  log("Executing with params: #{params.inspect}, operationName: #{operation_name}, variables: #{variables.inspect}")
40
- result = execute(params: params, operation_name: operation_name, variables: variables, context: context)
42
+ result = execute(params:, operation_name:, variables:, context:)
41
43
  status_code = response_status(result)
42
44
 
43
45
  [
44
46
  status_code,
45
- response_headers(result, status_code: status_code),
47
+ response_headers(result, status_code:),
46
48
  [response_body(result)]
47
49
  ]
48
50
  rescue AmbiguousParamError => e
@@ -74,12 +76,15 @@ module RackGraphql
74
76
  { 'Content-Type' => 'application/json', STATUS_CODE_HEADER_NAME => status_code },
75
77
  [Oj.dump('errors' => [exception_hash(e)])]
76
78
  ]
79
+ ensure
80
+ request_epilogue.call
77
81
  end
78
82
 
79
83
  private
80
84
 
81
85
  attr_reader :schema, :app_name, :logger, :context_handler,
82
- :log_exception_backtrace, :error_status_code_map, :re_raise_exceptions
86
+ :log_exception_backtrace, :error_status_code_map,
87
+ :re_raise_exceptions, :request_epilogue
83
88
 
84
89
  def post_request?(env)
85
90
  env['REQUEST_METHOD'] == 'POST'
@@ -116,14 +121,14 @@ module RackGraphql
116
121
 
117
122
  def execute(params:, operation_name:, variables:, context:)
118
123
  if valid_multiplex?(params)
119
- execute_multi(params['_json'], operation_name: operation_name, variables: variables, context: context)
124
+ execute_multi(params['_json'], operation_name:, variables:, context:)
120
125
  else
121
- execute_single(params['query'], operation_name: operation_name, variables: variables, context: context)
126
+ execute_single(params['query'], operation_name:, variables:, context:)
122
127
  end
123
128
  end
124
129
 
125
130
  def execute_single(query, operation_name:, variables:, context:)
126
- schema.execute(query, operation_name: operation_name, variables: variables, context: context)
131
+ schema.execute(query, operation_name:, variables:, context:)
127
132
  end
128
133
 
129
134
  def valid_multiplex?(params)
@@ -134,9 +139,9 @@ module RackGraphql
134
139
  queries = queries_params.map do |param|
135
140
  {
136
141
  query: param['query'],
137
- operation_name: operation_name,
138
- variables: variables,
139
- context: context
142
+ operation_name:,
143
+ variables:,
144
+ context:
140
145
  }
141
146
  end
142
147
 
@@ -1,3 +1,3 @@
1
1
  module RackGraphql
2
- VERSION = '3.2.0'.freeze
2
+ VERSION = '3.3.0'.freeze
3
3
  end
data/rack-graphql.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.required_ruby_version = '>= 3.0'
27
+ spec.required_ruby_version = '>= 3.1'
28
28
 
29
29
  spec.add_dependency 'graphql', '~> 2.0'
30
30
  spec.add_dependency 'oj'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -101,14 +101,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: '3.0'
104
+ version: '3.1'
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.4.21
111
+ rubygems_version: 3.4.22
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Rack middleware implementing graphql endpoint.