rack-graphql 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96ec802b9de117754bdea93534b69eb47be05796d31ecc362d2c1ac32d4ab929
4
- data.tar.gz: f87c56ccc52c047e35ebde5777e7a0ff171e61263c6e58fe1b7312be47e41561
3
+ metadata.gz: 0d1aad090a41b8371934fb35708504a1c08d473aa4991607119fd98485adefbf
4
+ data.tar.gz: 25902f5ffc962398799a20fe3bdeb4dd7b3dae772d7f5bbcddbd267c8f9eb6d4
5
5
  SHA512:
6
- metadata.gz: 2637be8f7dc262397347f60d89133cbfb354c3943b7b2e16343bf2ec26cb2ffd127eedfb0a0d255cc29fadff3c02005373539e2325b300b655f000ad6f55dbac
7
- data.tar.gz: 4edf965d3d98f562618479721323adffc7093bdb34efeba9e495af8157e3690855f82d3f0dbcd77b49e4cad38247fe3c43dd6dd14efd8a1282d306e1dd6ddb70
6
+ metadata.gz: d5daf847af3b599990248a75664aed30015c88b136bf8a91f530a81716d8739a8dbd3fc272e46bfe36abbc9b1b1f2ad50968e1da64697df23e85adee5183b519
7
+ data.tar.gz: dd3e2c521fa4112b3c177f29e4a0a53d94036e4aabca5c50b43c79518828ac5140ddd2b94bd41a571aa23ebb7cc45f66af4c1fc1c27df92b8ebbffa8ade55612
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.4.0 - 2020-09-39
4
+
5
+ - Use `http_status` from `ExecutionError` for http response
6
+
3
7
  ## 2.3.0 - 2020-09-39
4
8
 
5
9
  - Add `error_status_code_map` option to `RackGraphql::Application`.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-graphql (2.3.1)
4
+ rack-graphql (2.4.0)
5
5
  graphql (~> 1.11)
6
6
  oj
7
7
  rack (~> 2.2)
@@ -13,7 +13,7 @@ GEM
13
13
  awesome_print (1.8.0)
14
14
  coderay (1.1.3)
15
15
  diff-lcs (1.4.4)
16
- graphql (1.11.4)
16
+ graphql (1.11.5)
17
17
  method_source (1.0.0)
18
18
  oj (3.10.14)
19
19
  parallel (1.19.2)
@@ -1,5 +1,6 @@
1
1
  module RackGraphql
2
2
  class Middleware
3
+ DEFAULT_STATUS_CODE = 200
3
4
  DEFAULT_ERROR_STATUS_CODE = 500
4
5
 
5
6
  def initialize(
@@ -34,7 +35,7 @@ module RackGraphql
34
35
  result = execute(params: params, operation_name: operation_name, variables: variables, context: context)
35
36
 
36
37
  [
37
- 200,
38
+ response_status(result),
38
39
  response_headers(result),
39
40
  [response_body(result)]
40
41
  ]
@@ -136,6 +137,13 @@ module RackGraphql
136
137
  end
137
138
  end
138
139
 
140
+ def response_status(result)
141
+ return DEFAULT_STATUS_CODE if result.is_a?(Array)
142
+
143
+ errors = result.to_h["errors"] || []
144
+ errors.map { |e| e["http_status"] }.compact.first || DEFAULT_STATUS_CODE
145
+ end
146
+
139
147
  def response_body(result = nil)
140
148
  if result_subscription?(result)
141
149
  body = result.to_h
@@ -1,3 +1,3 @@
1
1
  module RackGraphql
2
- VERSION = '2.3.1'.freeze
2
+ VERSION = '2.4.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.3.1
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik