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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/lib/rack_graphql/middleware.rb +9 -1
- data/lib/rack_graphql/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0d1aad090a41b8371934fb35708504a1c08d473aa4991607119fd98485adefbf
|
|
4
|
+
data.tar.gz: 25902f5ffc962398799a20fe3bdeb4dd7b3dae772d7f5bbcddbd267c8f9eb6d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5daf847af3b599990248a75664aed30015c88b136bf8a91f530a81716d8739a8dbd3fc272e46bfe36abbc9b1b1f2ad50968e1da64697df23e85adee5183b519
|
|
7
|
+
data.tar.gz: dd3e2c521fa4112b3c177f29e4a0a53d94036e4aabca5c50b43c79518828ac5140ddd2b94bd41a571aa23ebb7cc45f66af4c1fc1c27df92b8ebbffa8ade55612
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rack-graphql (2.
|
|
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.
|
|
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
|
-
|
|
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
|
data/lib/rack_graphql/version.rb
CHANGED