graphql-hive 0.4.0 → 0.4.1

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: 8ea70bc7d8c7b0eb080aaa36993b4c2e5f42b3561e59e07e0bb2a41cee52ac34
4
- data.tar.gz: 210ea3ca3499a6dd7fdae1d732ad3dbf96e1c9ed5d4b248810bfc3821dd758c6
3
+ metadata.gz: fa05eaf88fa4240d8ee2364b48a2b7152eec226c2d657156a87efdb5f98eb2c3
4
+ data.tar.gz: 72e529bf8227f49d5a6c3602c5375feee671263f0e3df31c6b60cd034aff0910
5
5
  SHA512:
6
- metadata.gz: 5633e2cbd66d7e3a2d91f73329f25bb3a54d276e70aa07575bff9f79f9438666a2738dcc280ad7438b59d1ac1e9faae848ad643d173ad0b37a8676d1292229bb
7
- data.tar.gz: 311b33c5898a58425637c2aa8cecdc1d4574a7d84bd9d7e3183a5e8fa8c960b083be900a6bb09d8050d533b3003ce9a0115267f49b9595176d9a0fd8201e25a9
6
+ metadata.gz: 3669a7e7bedabc6b8dfd3b471fa921bfb34aafed0a5fcc927baca80d55766903ff9ea7aad55460cb72ab8fd38d3f54cf91b1ef345ddb7789048b7c898f4b36fd
7
+ data.tar.gz: 003c658d94088ea6f89b4a37b2124f907fad3240bf9e2150fffe5ca62d9e2d78ab096f7fe6363e2b7a361f82e7fb2a711c3670ce5e8477986cacae5c8991fbb4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-hive (0.4.0)
4
+ graphql-hive (0.4.1)
5
5
  graphql (>= 2.3, < 3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- graphql-hive (0.4.0)
4
+ graphql-hive (0.4.1)
5
5
  graphql (>= 2.3, < 3)
6
6
 
7
7
  GEM
@@ -20,22 +20,34 @@ module GraphQL
20
20
  path: path
21
21
  )
22
22
 
23
+ http = setup_http(uri)
24
+ request = build_request(uri, body)
25
+ response = http.request(request)
26
+
27
+ @options[:logger].debug(response.inspect)
28
+ @options[:logger].debug(response.body.inspect)
29
+ rescue StandardError => e
30
+ @options[:logger].fatal("Failed to send data: #{e}")
31
+ raise e
32
+ end
33
+
34
+ def setup_http(uri)
23
35
  http = ::Net::HTTP.new(uri.host, uri.port)
24
36
  http.use_ssl = @options[:port].to_s == '443'
25
37
  http.read_timeout = 2
38
+ http
39
+ end
40
+
41
+ def build_request(uri, body)
26
42
  request = Net::HTTP::Post.new(uri.request_uri)
43
+ request['Authorization'] = @options[:token]
44
+ request['X-Usage-API-Version'] = '2'
27
45
  request['content-type'] = 'application/json'
28
- request['x-api-token'] = @options[:token]
29
46
  request['User-Agent'] = "Hive@#{Graphql::Hive::VERSION}"
30
47
  request['graphql-client-name'] = 'Hive Ruby Client'
31
48
  request['graphql-client-version'] = Graphql::Hive::VERSION
32
49
  request.body = JSON.generate(body)
33
- response = http.request(request)
34
-
35
- @options[:logger].debug(response.inspect)
36
- @options[:logger].debug(response.body.inspect)
37
- rescue StandardError => e
38
- @options[:logger].fatal("Failed to send data: #{e}")
50
+ request
39
51
  end
40
52
  end
41
53
  end
@@ -128,8 +128,7 @@ module GraphQL
128
128
  execution: {
129
129
  ok: errors[:errorsTotal].zero?,
130
130
  duration: duration,
131
- errorsTotal: errors[:errorsTotal],
132
- errors: errors[:errors]
131
+ errorsTotal: errors[:errorsTotal]
133
132
  }
134
133
  }
135
134
 
@@ -148,12 +147,11 @@ module GraphQL
148
147
  end
149
148
 
150
149
  def errors_from_results(results)
151
- acc = { errorsTotal: 0, errors: [] }
150
+ acc = { errorsTotal: 0 }
152
151
  results.each do |result|
153
152
  errors = result.to_h.fetch('errors', [])
154
- errors.each do |error|
153
+ errors.each do
155
154
  acc[:errorsTotal] += 1
156
- acc[:errors] << { message: error['message'], path: error['path']&.join('.') }
157
155
  end
158
156
  end
159
157
  acc
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Graphql
4
4
  module Hive
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-hive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charly POLY
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-19 00:00:00.000000000 Z
11
+ date: 2024-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.5.9
155
+ rubygems_version: 3.5.16
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: '"GraphQL Hive integration for `graphql-ruby`"'