inigorb 0.27.5 → 0.27.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inigo-darwin-amd64.dylib +0 -0
- data/lib/inigo-darwin-arm64.dylib +0 -0
- data/lib/inigo-linux-amd64.so +0 -0
- data/lib/inigo-linux-arm64.so +0 -0
- data/lib/inigo-windows-amd64.dll +0 -0
- data/lib/inigo-windows-arm64.dll +0 -0
- data/lib/inigorb.rb +42 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6958605469a47112e9986e2750fb21cd0828ce2f57bb826e221f96bb52549cd
|
4
|
+
data.tar.gz: 42387b988b13ca15e30f99d64aee75a19eda115fd25392a4a13ec93249c388a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d7cad1a8f9dd997d4c834d6c9d953c5e1e4c0f50d3ad9c4244740be7760e3d443badaaaa8294e32acd1b33cd53fa086af642ca99839f98ef4007254338cf7e6
|
7
|
+
data.tar.gz: a09eebe058d895f2b0aee923ba708a1ca26a8fa0497a1eb9e6abcb7cd730ff808c0b944de6500b3be32c7093711e7f3da628f76e2807bc3c145a3abc852ddb35
|
Binary file
|
Binary file
|
data/lib/inigo-linux-amd64.so
CHANGED
Binary file
|
data/lib/inigo-linux-arm64.so
CHANGED
Binary file
|
data/lib/inigo-windows-amd64.dll
CHANGED
Binary file
|
data/lib/inigo-windows-arm64.dll
CHANGED
Binary file
|
data/lib/inigorb.rb
CHANGED
@@ -63,13 +63,15 @@ module Inigo
|
|
63
63
|
|
64
64
|
request = Rack::Request.new(env)
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
path = self.class.path
|
67
|
+
path += "/" unless path.end_with?("/")
|
68
|
+
# 'path' guard -> /graphql, /graphql/whatever
|
69
|
+
if request.path != self.class.path && !request.path.start_with?(path)
|
68
70
|
return @app.call(env)
|
69
71
|
end
|
70
72
|
|
71
73
|
# GraphiQL request
|
72
|
-
if request.get? &&
|
74
|
+
if request.get? && env['HTTP_ACCEPT'].include?('text/html')
|
73
75
|
return @app.call(env)
|
74
76
|
end
|
75
77
|
|
@@ -84,9 +86,16 @@ module Inigo
|
|
84
86
|
# Read request from body
|
85
87
|
request.body.each { |chunk| gReq += chunk }
|
86
88
|
|
87
|
-
if self.class.operation_store.present? &&
|
89
|
+
if self.class.operation_store.present? && has_operation_id?(gReq)
|
88
90
|
parsed = JSON.parse(gReq)
|
89
|
-
|
91
|
+
operationId = get_operation_id(parsed)
|
92
|
+
|
93
|
+
if !operationId
|
94
|
+
request.body.rewind
|
95
|
+
return @app.call(env)
|
96
|
+
end
|
97
|
+
|
98
|
+
parts = operationId.split('/')
|
90
99
|
# Query can't be resolved
|
91
100
|
if parts.length != 2
|
92
101
|
request.body.rewind
|
@@ -114,24 +123,9 @@ module Inigo
|
|
114
123
|
end
|
115
124
|
request.body.rewind
|
116
125
|
elsif request.get?
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
req.merge!('query' => request.params['query'])
|
121
|
-
end
|
122
|
-
|
123
|
-
if request.params['operationName']
|
124
|
-
req.merge!('operationName' => request.params['operationName'])
|
125
|
-
end
|
126
|
-
|
127
|
-
if request.params['variables']
|
128
|
-
req.merge!('variables' => request.params['variables'])
|
129
|
-
end
|
130
|
-
|
131
|
-
if request.params['operationId']
|
132
|
-
req.merge!('operationId' => request.params['operationId'])
|
133
|
-
if self.class.operation_store
|
134
|
-
parts = request.params['operationId'].split('/')
|
126
|
+
operation_id = get_operation_id(request.params)
|
127
|
+
if operation_id && self.class.operation_store
|
128
|
+
parts = operation_id.split('/')
|
135
129
|
# Query can't be resolved
|
136
130
|
if parts.length != 2
|
137
131
|
return @app.call(env)
|
@@ -143,17 +137,19 @@ module Inigo
|
|
143
137
|
end
|
144
138
|
|
145
139
|
if data.name
|
146
|
-
|
140
|
+
request.params['operationName'] = data.name
|
147
141
|
end
|
148
142
|
|
149
143
|
if data.body
|
150
|
-
|
144
|
+
request.params['query'] = data.body
|
151
145
|
end
|
152
|
-
|
146
|
+
|
147
|
+
# Update the env with the modified query string
|
148
|
+
env['QUERY_STRING'] = Rack::Utils.build_nested_query(request.params)
|
153
149
|
end
|
154
150
|
|
155
151
|
# Read request from query param
|
156
|
-
gReq = JSON.dump(
|
152
|
+
gReq = JSON.dump(request.params)
|
157
153
|
end
|
158
154
|
|
159
155
|
q = Query.new(self.class.instance, gReq)
|
@@ -280,5 +276,24 @@ module Inigo
|
|
280
276
|
[status, headers, [JSON.dump(response_hash)]]
|
281
277
|
end
|
282
278
|
|
279
|
+
# operates with string data not to parse the request body unnecessary
|
280
|
+
def has_operation_id?(str_data)
|
281
|
+
# Relay / Apollo 1.x and Apollo Link have the same field just in different places.
|
282
|
+
str_data.include?('operationId')
|
283
|
+
end
|
284
|
+
|
285
|
+
# extracts operation id from parsed body hash
|
286
|
+
def get_operation_id(json_data)
|
287
|
+
# Relay / Apollo 1.x
|
288
|
+
if json_data.include?('operationId')
|
289
|
+
json_data['operationId']
|
290
|
+
# Apollo Link
|
291
|
+
elsif json_data.include?('extensions') && json_data['extensions'].include?('operationId')
|
292
|
+
json_data['extensions']['operationId']
|
293
|
+
else
|
294
|
+
nil
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
283
298
|
end
|
284
299
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inigorb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.27.
|
4
|
+
version: 0.27.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inigo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|