graphql-hive 0.5.5 → 0.6.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/Gemfile.lock +1 -1
- data/README.md +9 -0
- data/lib/graphql-hive/client.rb +5 -1
- data/lib/graphql-hive/version.rb +1 -1
- data/lib/graphql-hive.rb +22 -10
- 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: 87d3b825ce1bfdcf80d8ce3ca76848804bb4ee8b6a0dce1288a91da51d9b0e23
|
4
|
+
data.tar.gz: 6d8c6971ac626be6b790e53e98500f721b39b05f7ef496cd3add8b3616791a65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d934a8056bac2871c626b36a7404384aebf2810b462a7ea5b4b3f21ce71957d2555adf257542f2074c32985c9437b4e931228c40b9d89a17776d9f9e58feb0b4
|
7
|
+
data.tar.gz: 7d1a9a441c579088a70d24dbe08ac599c1a5f0edbaa4fcd5257de86cea6528d1fd7664120d408ff7ff5b023434f9e22222ed052214506fe3dbd52f09ddb3fa24
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,6 +28,10 @@
|
|
28
28
|
|
29
29
|
If you are using Hive as a service, please refer to our documentation: https://docs.graphql-hive.com/features/tokens.
|
30
30
|
|
31
|
+
### Organization-level tokens
|
32
|
+
|
33
|
+
If you are using an organization-level access token (tokens starting with `hvo1/`), you must also provide a `target` parameter to specify which target the usage data should be reported to. See the [organization access tokens documentation](https://the-guild.dev/graphql/hive/docs/migration-guides/organization-access-tokens#usage-data-reporting) for more details.
|
34
|
+
|
31
35
|
## 1. Install the `graphql-hive` gem
|
32
36
|
|
33
37
|
```
|
@@ -48,6 +52,8 @@ class Schema < GraphQL::Schema
|
|
48
52
|
GraphQL::Hive,
|
49
53
|
{
|
50
54
|
token: '<YOUR_TOKEN>',
|
55
|
+
# target is only needed if you're using an organization level token
|
56
|
+
target: 'your-org/your-project/production', # or target UUID
|
51
57
|
reporting: {
|
52
58
|
author: ENV['GITHUB_USER'],
|
53
59
|
commit: ENV['GITHUB_COMMIT']
|
@@ -148,6 +154,9 @@ class MySchema < GraphQL::Schema
|
|
148
154
|
{
|
149
155
|
# Token is the only required configuration value.
|
150
156
|
token: 'YOUR-REGISTRY-TOKEN',
|
157
|
+
# Target is required when using organization-level tokens (tokens starting with 'hvo1/').
|
158
|
+
# Can be a target slug (e.g., 'org/project/target') or target UUID.
|
159
|
+
target: 'your-org/your-project/production',
|
151
160
|
#
|
152
161
|
# The following are optional configuration values.
|
153
162
|
#
|
data/lib/graphql-hive/client.rb
CHANGED
@@ -12,6 +12,10 @@ module GraphQL
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def send(path, body, _log_type)
|
15
|
+
path = path.to_s
|
16
|
+
if path == "/usage" && @options[:target] && @options[:target] != ""
|
17
|
+
path = "/usage/#{@options[:target]}"
|
18
|
+
end
|
15
19
|
uri =
|
16
20
|
URI::HTTP.build(
|
17
21
|
scheme: (@options[:port].to_s == "443") ? "https" : "http",
|
@@ -45,7 +49,7 @@ module GraphQL
|
|
45
49
|
|
46
50
|
def build_request(uri, body)
|
47
51
|
request = Net::HTTP::Post.new(uri.request_uri)
|
48
|
-
request["Authorization"] = @options[:token]
|
52
|
+
request["Authorization"] = "Bearer #{@options[:token]}"
|
49
53
|
request["X-Usage-API-Version"] = "2"
|
50
54
|
request["content-type"] = "application/json"
|
51
55
|
request["User-Agent"] = "Hive@#{Graphql::Hive::VERSION}"
|
data/lib/graphql-hive/version.rb
CHANGED
data/lib/graphql-hive.rb
CHANGED
@@ -39,7 +39,8 @@ module GraphQL
|
|
39
39
|
buffer_size: 50,
|
40
40
|
queue_size: 1000,
|
41
41
|
logger: nil,
|
42
|
-
collect_usage_sampling: 1.0
|
42
|
+
collect_usage_sampling: 1.0,
|
43
|
+
target: nil
|
43
44
|
}.freeze
|
44
45
|
|
45
46
|
self.platform_keys = {
|
@@ -141,10 +142,14 @@ module GraphQL
|
|
141
142
|
}
|
142
143
|
options[:logger].level = options[:debug] ? Logger::DEBUG : Logger::INFO
|
143
144
|
end
|
144
|
-
if !options.include?(:token) && (!options.include?(:enabled) || options
|
145
|
+
if !options.include?(:token) && (!options.include?(:enabled) || options[:enabled])
|
145
146
|
options[:logger].warn("`token` options is missing")
|
146
147
|
options[:enabled] = false
|
147
148
|
false
|
149
|
+
elsif options[:token]&.start_with?("hvo1/") && (options[:target].nil? || options[:target] == "")
|
150
|
+
options[:logger].warn("Organization-level token detected but `target` option is missing. Target must be specified for organization-level tokens.")
|
151
|
+
options[:enabled] = false
|
152
|
+
false
|
148
153
|
elsif options[:report_schema] &&
|
149
154
|
(
|
150
155
|
!options.include?(:reporting) ||
|
@@ -168,18 +173,25 @@ module GraphQL
|
|
168
173
|
def send_report_schema(schema)
|
169
174
|
sdl = GraphQL::Schema::Printer.new(schema).print_schema
|
170
175
|
|
176
|
+
input = {
|
177
|
+
sdl: sdl,
|
178
|
+
author: @options[:reporting][:author],
|
179
|
+
commit: @options[:reporting][:commit],
|
180
|
+
service: @options[:reporting][:service_name],
|
181
|
+
url: @options[:reporting][:service_url],
|
182
|
+
force: true
|
183
|
+
}
|
184
|
+
|
185
|
+
# Add target for organization-level tokens
|
186
|
+
if @options[:target]
|
187
|
+
input[:target] = @options[:target]
|
188
|
+
end
|
189
|
+
|
171
190
|
body = {
|
172
191
|
query: REPORT_SCHEMA_MUTATION,
|
173
192
|
operationName: "schemaPublish",
|
174
193
|
variables: {
|
175
|
-
input:
|
176
|
-
sdl: sdl,
|
177
|
-
author: @options[:reporting][:author],
|
178
|
-
commit: @options[:reporting][:commit],
|
179
|
-
service: @options[:reporting][:service_name],
|
180
|
-
url: @options[:reporting][:service_url],
|
181
|
-
force: true
|
182
|
-
}
|
194
|
+
input: input
|
183
195
|
}
|
184
196
|
}
|
185
197
|
|
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
|
+
version: 0.6.0
|
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-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|