rack-graphql 1.0.0 → 1.1.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/.travis.yml +3 -3
- data/Gemfile.lock +7 -7
- data/lib/rack_graphql/application.rb +2 -2
- data/lib/rack_graphql/middleware.rb +11 -3
- data/lib/rack_graphql/version.rb +1 -1
- 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: 9dd40d40ed2382e719c6800b9df0f155a3007d9c28cac18c56df5b31e48632c0
|
4
|
+
data.tar.gz: c98f7a2d5d9964436db365c1c5209e4cefb08f56010fb674023adac01f3128c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36ef93a32e777d2c9a56c92670eecc0453868063c0521f281ac2910a71dc7a1148d2242ba3feeed9df951c233964a989b23fcf9fd0bc8a66a011836a6c2a01dd
|
7
|
+
data.tar.gz: cc2758913de2a10cf0f36dfd6c5beb4a06b516a72401c145a8fd0463332b35cfa4038c00787eaba46be7cce3b8b82d90de97c7e58405c33a628b1274724cb768
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-graphql (1.
|
4
|
+
rack-graphql (1.1.0)
|
5
5
|
graphql (>= 1.9.0)
|
6
6
|
oj
|
7
7
|
rack (>= 2.0.0)
|
@@ -17,7 +17,7 @@ GEM
|
|
17
17
|
method_source (0.9.2)
|
18
18
|
oj (3.10.0)
|
19
19
|
parallel (1.19.1)
|
20
|
-
parser (2.
|
20
|
+
parser (2.7.0.1)
|
21
21
|
ast (~> 2.4.0)
|
22
22
|
pry (0.12.2)
|
23
23
|
coderay (~> 1.1.0)
|
@@ -31,15 +31,15 @@ GEM
|
|
31
31
|
rspec-core (~> 3.9.0)
|
32
32
|
rspec-expectations (~> 3.9.0)
|
33
33
|
rspec-mocks (~> 3.9.0)
|
34
|
-
rspec-core (3.9.
|
35
|
-
rspec-support (~> 3.9.
|
34
|
+
rspec-core (3.9.1)
|
35
|
+
rspec-support (~> 3.9.1)
|
36
36
|
rspec-expectations (3.9.0)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
38
|
rspec-support (~> 3.9.0)
|
39
|
-
rspec-mocks (3.9.
|
39
|
+
rspec-mocks (3.9.1)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
41
|
rspec-support (~> 3.9.0)
|
42
|
-
rspec-support (3.9.
|
42
|
+
rspec-support (3.9.2)
|
43
43
|
rubocop (0.78.0)
|
44
44
|
jaro_winkler (~> 1.5.1)
|
45
45
|
parallel (~> 1.10)
|
@@ -47,7 +47,7 @@ GEM
|
|
47
47
|
rainbow (>= 2.2.2, < 4.0)
|
48
48
|
ruby-progressbar (~> 1.7)
|
49
49
|
unicode-display_width (>= 1.4.0, < 1.7)
|
50
|
-
rubocop-performance (1.5.
|
50
|
+
rubocop-performance (1.5.2)
|
51
51
|
rubocop (>= 0.71.0)
|
52
52
|
ruby-progressbar (1.10.1)
|
53
53
|
unicode-display_width (1.6.0)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module RackGraphql
|
2
2
|
class Application
|
3
|
-
def self.call(schema:, app_name: 'rack-graphql-service', context_handler: nil,
|
3
|
+
def self.call(schema:, app_name: 'rack-graphql-service', logger: nil, context_handler: nil,
|
4
4
|
health_route: true, health_response_builder: RackGraphql::HealthResponseBuilder)
|
5
5
|
|
6
6
|
::Rack::Builder.new do
|
7
7
|
map '/graphql' do
|
8
|
-
run RackGraphql::Middleware.new(schema: schema, context_handler: context_handler)
|
8
|
+
run RackGraphql::Middleware.new(schema: schema, context_handler: context_handler, logger: logger)
|
9
9
|
end
|
10
10
|
|
11
11
|
if health_route
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module RackGraphql
|
2
2
|
class Middleware
|
3
|
-
def initialize(schema:, context_handler: nil)
|
3
|
+
def initialize(schema:, logger: nil, context_handler: nil)
|
4
4
|
@schema = schema
|
5
|
+
@logger = logger
|
5
6
|
@context_handler = context_handler || ->(_) {}
|
6
7
|
end
|
7
8
|
|
@@ -16,10 +17,12 @@ module RackGraphql
|
|
16
17
|
operation_name = params['operationName']
|
17
18
|
context = context_handler.call(env)
|
18
19
|
|
20
|
+
log("Executing with params: #{params.inspect}, operationName: #{operation_name}, variables: #{variables.inspect}")
|
19
21
|
result = execute(params: params, operation_name: operation_name, variables: variables, context: context)
|
20
22
|
|
21
23
|
[200, response_headers(result), [response_body(result)]]
|
22
|
-
rescue ArgumentError
|
24
|
+
rescue ArgumentError => e
|
25
|
+
log("Responded with #{e.class} because of #{e.message}")
|
23
26
|
[400, { 'Content-Type' => 'application/json' }, [Oj.dump({})]]
|
24
27
|
ensure
|
25
28
|
ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
|
@@ -27,7 +30,7 @@ module RackGraphql
|
|
27
30
|
|
28
31
|
private
|
29
32
|
|
30
|
-
attr_reader :schema, :context_handler
|
33
|
+
attr_reader :schema, :logger, :context_handler
|
31
34
|
|
32
35
|
def post_request?(env)
|
33
36
|
env['REQUEST_METHOD'] == 'POST'
|
@@ -116,5 +119,10 @@ module RackGraphql
|
|
116
119
|
|
117
120
|
result.subscription?
|
118
121
|
end
|
122
|
+
|
123
|
+
def log(message)
|
124
|
+
return unless logger
|
125
|
+
logger.debug("[rack-graphql] #{message}")
|
126
|
+
end
|
119
127
|
end
|
120
128
|
end
|
data/lib/rack_graphql/version.rb
CHANGED
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: 1.
|
4
|
+
version: 1.1.0
|
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:
|
12
|
+
date: 2020-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: graphql
|