graphql-hive 0.6.0 → 0.6.2
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/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/graphql-hive/client.rb +32 -9
- data/lib/graphql-hive/version.rb +1 -1
- data/lib/graphql-hive.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49d7ea84eecb7ee527720752d5fed3179acfdc56a97abf71e7e009e79c860a00
|
|
4
|
+
data.tar.gz: 5f69430570fe93bf637be7726fecf57fb396243a177c1705130b0f8b5c4cef6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d215ba7482205e18466b32d53f46fd9b2fcc18b3b0e144f5e824f844e856c904ab47d22153250f9529c44a3c3fea1ce4bdbccb548135018f61735e555c3d9825
|
|
7
|
+
data.tar.gz: b46ea3f3660e53d5c62e0c50b14f101740887d0b8256e4bada10f41cac540de632866bb039a6e9d66a9a3e444ee7684d9a960ea70cfb66a7b92872e29aee8e2a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -166,6 +166,10 @@ class MySchema < GraphQL::Schema
|
|
|
166
166
|
debug: false,
|
|
167
167
|
# A custom logger.
|
|
168
168
|
logger: MyLogger.new,
|
|
169
|
+
# Log request details at info level (default: false, logs at debug level). Details include request type, request path, and a unique request ID.
|
|
170
|
+
log_request_details: false,
|
|
171
|
+
# Log Hive errors (unsuccessful responses and exceptions) as warnings instead of errors (default: false, logs as errors).
|
|
172
|
+
warn_on_hive_errors: false,
|
|
169
173
|
# Endpoint and port of the Hive API. Change this if you are using a self-hosted Hive instance.
|
|
170
174
|
endpoint: 'app.graphql-hive.com',
|
|
171
175
|
port: 80,
|
data/lib/graphql-hive/client.rb
CHANGED
|
@@ -16,28 +16,32 @@ module GraphQL
|
|
|
16
16
|
if path == "/usage" && @options[:target] && @options[:target] != ""
|
|
17
17
|
path = "/usage/#{@options[:target]}"
|
|
18
18
|
end
|
|
19
|
-
uri =
|
|
20
|
-
URI::HTTP.build(
|
|
21
|
-
scheme: (@options[:port].to_s == "443") ? "https" : "http",
|
|
22
|
-
host: @options[:endpoint] || "app.graphql-hive.com",
|
|
23
|
-
port: @options[:port] || "443",
|
|
24
|
-
path: path
|
|
25
|
-
)
|
|
26
19
|
|
|
20
|
+
scheme = (@options[:port].to_s == "443") ? "https" : "http"
|
|
21
|
+
endpoint = @options[:endpoint] || "app.graphql-hive.com"
|
|
22
|
+
uri = URI::HTTP.build(
|
|
23
|
+
scheme: scheme,
|
|
24
|
+
host: endpoint,
|
|
25
|
+
port: @options[:port] || "443",
|
|
26
|
+
path: path
|
|
27
|
+
)
|
|
27
28
|
http = setup_http(uri)
|
|
28
29
|
request = build_request(uri, body)
|
|
30
|
+
|
|
31
|
+
log_request(request, scheme, endpoint, path)
|
|
32
|
+
|
|
29
33
|
response = http.request(request)
|
|
30
34
|
|
|
31
35
|
code = response.code.to_i
|
|
32
36
|
if code >= 400 && code < 500
|
|
33
37
|
error_message = "Unsuccessful response: #{response.code} - #{response.message}"
|
|
34
|
-
|
|
38
|
+
log_error("#{error_message} #{extract_error_details(response)}")
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
@options[:logger].debug(response.inspect)
|
|
38
42
|
@options[:logger].debug(response.body.inspect)
|
|
39
43
|
rescue => e
|
|
40
|
-
|
|
44
|
+
log_error("Failed to send data: #{e}")
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
def setup_http(uri)
|
|
@@ -55,10 +59,21 @@ module GraphQL
|
|
|
55
59
|
request["User-Agent"] = "Hive@#{Graphql::Hive::VERSION}"
|
|
56
60
|
request["graphql-client-name"] = "Hive Ruby Client"
|
|
57
61
|
request["graphql-client-version"] = Graphql::Hive::VERSION
|
|
62
|
+
request["X-Request-Id"] = SecureRandom.uuid
|
|
58
63
|
request.body = JSON.generate(body)
|
|
59
64
|
request
|
|
60
65
|
end
|
|
61
66
|
|
|
67
|
+
def log_request(request, scheme, endpoint, path)
|
|
68
|
+
log_message = "#{request.method} #{scheme}://#{endpoint}#{path} request id: #{request["X-Request-Id"]}"
|
|
69
|
+
|
|
70
|
+
if @options[:log_request_details]
|
|
71
|
+
@options[:logger].info(log_message)
|
|
72
|
+
else
|
|
73
|
+
@options[:logger].debug(log_message)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
62
77
|
def extract_error_details(response)
|
|
63
78
|
parsed_body = JSON.parse(response.body)
|
|
64
79
|
return unless parsed_body.is_a?(Hash) && parsed_body["errors"].is_a?(Array)
|
|
@@ -66,6 +81,14 @@ module GraphQL
|
|
|
66
81
|
rescue JSON::ParserError
|
|
67
82
|
"Could not parse response from Hive"
|
|
68
83
|
end
|
|
84
|
+
|
|
85
|
+
def log_error(message)
|
|
86
|
+
if @options[:warn_on_hive_errors]
|
|
87
|
+
@options[:logger].warn(message)
|
|
88
|
+
else
|
|
89
|
+
@options[:logger].error(message)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
69
92
|
end
|
|
70
93
|
end
|
|
71
94
|
end
|
data/lib/graphql-hive/version.rb
CHANGED
data/lib/graphql-hive.rb
CHANGED
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.6.
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Charly POLY
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-10-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: graphql
|
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
82
82
|
- !ruby/object:Gem::Version
|
|
83
83
|
version: '0'
|
|
84
84
|
requirements: []
|
|
85
|
-
rubygems_version: 3.5.
|
|
85
|
+
rubygems_version: 3.5.22
|
|
86
86
|
signing_key:
|
|
87
87
|
specification_version: 4
|
|
88
88
|
summary: '"GraphQL Hive integration for `graphql-ruby`"'
|