rack-graphql 1.0.0 → 1.1.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: e7f00f1a34ea61f6d51c99f959813d95719796d732a61b307a74644c7d1195b0
4
- data.tar.gz: 865e223d7fdeba8694b40cbb33ecfaa825d60ee8fffd939baf6d16db0d72a480
3
+ metadata.gz: 9dd40d40ed2382e719c6800b9df0f155a3007d9c28cac18c56df5b31e48632c0
4
+ data.tar.gz: c98f7a2d5d9964436db365c1c5209e4cefb08f56010fb674023adac01f3128c9
5
5
  SHA512:
6
- metadata.gz: 60abee68f5762fe9aa1b7e0a1ca70e0431bfa898fb6324e2c15fb21b7a3ec67b5957332ab9cf154f73b35620d3efeb35cdfb37a026229c5af9b8611e4253c58f
7
- data.tar.gz: e87197a5ce76d2e57be41bcc30efb1b28541ea04e3e19919595a4c639d5b3a9e7ac196f1739378cc0072c535985546ca329726e4da68fc6d451ebf8b93905c21
6
+ metadata.gz: 36ef93a32e777d2c9a56c92670eecc0453868063c0521f281ac2910a71dc7a1148d2242ba3feeed9df951c233964a989b23fcf9fd0bc8a66a011836a6c2a01dd
7
+ data.tar.gz: cc2758913de2a10cf0f36dfd6c5beb4a06b516a72401c145a8fd0463332b35cfa4038c00787eaba46be7cce3b8b82d90de97c7e58405c33a628b1274724cb768
data/.travis.yml CHANGED
@@ -3,8 +3,8 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.7
7
- - 2.6.5
8
- before_install: gem install bundler -v 2.0.2
6
+ - 2.5
7
+ - 2.6
8
+ before_install: gem install bundler
9
9
  script:
10
10
  - bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-graphql (1.0.0)
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.6.5.0)
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.0)
35
- rspec-support (~> 3.9.0)
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.0)
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.0)
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.1)
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
@@ -1,3 +1,3 @@
1
1
  module RackGraphql
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.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: 1.0.0
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: 2019-12-20 00:00:00.000000000 Z
12
+ date: 2020-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql