graphql-hive 0.5.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faf3390c1974107943ff70715481c0986b931b8d7eb8b3fb3f6e38899192d958
4
- data.tar.gz: 345f4c6b5a14a83b96d596a007fa1b901c19230555e69f64ac2db421b851089b
3
+ metadata.gz: 87d3b825ce1bfdcf80d8ce3ca76848804bb4ee8b6a0dce1288a91da51d9b0e23
4
+ data.tar.gz: 6d8c6971ac626be6b790e53e98500f721b39b05f7ef496cd3add8b3616791a65
5
5
  SHA512:
6
- metadata.gz: 36d075c01c81e9e9c1c359a05b1787227c0f13cf54f45437ef09cbfb72a95c53c6b1a83777e76ec724fbbe15af1fca9e65ec4ea1f451cc489500458a4c29eeec
7
- data.tar.gz: d211dd70a405153f492254210c330f0d5fbd6e63d8d96a5267ec651eb8712654238780f997b1ee95a1f1bbbba5b1e1440a2539ec1ae1a9edeca1b61cbb537f18
6
+ metadata.gz: d934a8056bac2871c626b36a7404384aebf2810b462a7ea5b4b3f21ce71957d2555adf257542f2074c32985c9437b4e931228c40b9d89a17776d9f9e58feb0b4
7
+ data.tar.gz: 7d1a9a441c579088a70d24dbe08ac599c1a5f0edbaa4fcd5257de86cea6528d1fd7664120d408ff7ff5b023434f9e22222ed052214506fe3dbd52f09ddb3fa24
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-hive (0.5.4)
5
- graphql (>= 2.3, < 3)
4
+ graphql-hive (0.6.0)
5
+ graphql (>= 2.4.12, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -19,8 +19,11 @@ GEM
19
19
  irb (~> 1.10)
20
20
  reline (>= 0.3.8)
21
21
  diff-lcs (1.5.1)
22
- graphql (2.3.7)
22
+ fiber-storage (1.0.0)
23
+ graphql (2.4.14)
23
24
  base64
25
+ fiber-storage
26
+ logger
24
27
  hashdiff (1.1.1)
25
28
  io-console (0.7.2)
26
29
  irb (1.14.1)
@@ -29,6 +32,7 @@ GEM
29
32
  json (2.7.2)
30
33
  language_server-protocol (3.17.0.3)
31
34
  lint_roller (1.1.0)
35
+ logger (1.6.6)
32
36
  mustermann (2.0.2)
33
37
  ruby2_keywords (~> 0.0.1)
34
38
  parallel (1.26.3)
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/graphql-hive.gemspec CHANGED
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
24
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
25
  end
26
26
 
27
- spec.add_dependency "graphql", ">= 2.3", "< 3"
27
+ spec.add_dependency "graphql", ">= 2.4.12", "< 3"
28
28
  end
@@ -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}"
@@ -108,7 +108,8 @@ module GraphQL
108
108
  analyzer = GraphQL::Hive::Analyzer.new(query)
109
109
  visitor = GraphQL::Analysis::AST::Visitor.new(
110
110
  query: query,
111
- analyzers: [analyzer]
111
+ analyzers: [analyzer],
112
+ timeout: nil
112
113
  )
113
114
 
114
115
  result = visitor.visit
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Graphql
4
4
  module Hive
5
- VERSION = "0.5.4"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
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.enabled)
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.5.4
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: 2024-12-21 00:00:00.000000000 Z
11
+ date: 2025-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.3'
19
+ version: 2.4.12
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '3'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '2.3'
29
+ version: 2.4.12
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3'