graphql-hive 0.4.2 → 0.5.1

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: b2df4ea1405ff374b1d534b4b771e95a6e28765d0befce95492b482d675c0905
4
- data.tar.gz: 305c9e57226ea9943fb8f14d1b6b85a757455b2be8ccead3ade9d6c4c2bdf2b5
3
+ metadata.gz: 4176f281928e52d551ae77d96f837f449e32ecc4636d9f3c160c6c36121cef43
4
+ data.tar.gz: 71b3d0d1740cd707321c4970ad608fd73cae893561a6aa51b6ef288c2a955fc0
5
5
  SHA512:
6
- metadata.gz: 66216491e6445d6e3abe05689a820fe881da34048f2f676970e81e24ae5fea21300d1f0c1924d53e0a5925cfc4b715338cee4a8f913cef888538c9ad6855ef72
7
- data.tar.gz: f56b6f52dd900b2073fb229364a6cb9ab3d74f482ea7ae81e90be906d6912c195a7b6de08c91ac987c2029ae3abbe84951a561615b1152f1e9441bb92fce3b21
6
+ metadata.gz: 5dd8fe627ef820bb26b8c20a3eb5fb9946bd87b4d3c36cff52c508f02aca17645ebc105314ada908b2dd926b176134e8e83d6c86b891849b5cf3c98d86db1ad0
7
+ data.tar.gz: b66d19f472e1e0034ae4eb42ab7f1ec14814216a6e7e71660aaaec4948c9b85287f947595043a41d9b31f7308cf9039af2978ef4af59f5edc2ed822410d890f8
@@ -8,33 +8,26 @@ on:
8
8
  - master
9
9
 
10
10
  jobs:
11
- rubocop:
11
+ standard:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v4
15
-
16
- - uses: ruby/setup-ruby@2a9a743e19810b9f3c38060637daf594dbd7b37f
17
- with:
18
- ruby-version: '3.3'
19
- bundler-cache: true
20
-
21
- - run: bundle exec rake rubocop
22
-
14
+ - name: Standard Ruby
15
+ uses: standardrb/standard-ruby-action@v1
23
16
  test:
24
17
  strategy:
25
18
  fail-fast: false
26
19
  matrix:
27
20
  ruby-version:
28
- - '3.1'
29
- - '3.2'
30
- - '3.3'
21
+ - "3.1"
22
+ - "3.2"
23
+ - "3.3"
31
24
  runs-on: ubuntu-latest
32
25
  steps:
33
- - uses: actions/checkout@v4
26
+ - uses: actions/checkout@v4
34
27
 
35
- - uses: ruby/setup-ruby@2a9a743e19810b9f3c38060637daf594dbd7b37f
36
- with:
37
- ruby-version: ${{ matrix.ruby-version }}
38
- bundler-cache: true
28
+ - uses: ruby/setup-ruby@2a9a743e19810b9f3c38060637daf594dbd7b37f
29
+ with:
30
+ ruby-version: ${{ matrix.ruby-version }}
31
+ bundler-cache: true
39
32
 
40
- - run: bundle exec rake spec
33
+ - run: bundle exec rake spec
data/.gitignore CHANGED
@@ -11,3 +11,9 @@
11
11
  .rspec_status
12
12
  *.gem
13
13
  k6/node_modules/
14
+
15
+ # IDEs
16
+ .idea
17
+
18
+ # k6
19
+ node_modules
data/.rubocop.yml CHANGED
@@ -1,41 +1,10 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
3
- NewCops: enable
4
- Exclude:
5
- - 'examples/**/*'
6
- - 'k6/**/*'
7
- - 'gemfiles/**/*'
8
- - 'tmp/**/*'
9
- - 'vendor/**/*'
10
-
11
- Metrics/BlockLength:
12
- Exclude:
13
- - 'spec/**/*'
14
-
15
- Layout/LineLength:
16
- Exclude:
17
- - 'spec/**/*'
18
-
19
- Naming/FileName:
20
- Enabled: false
21
-
22
- Style/ClassVars:
23
- Enabled: false
24
-
25
- Metrics/AbcSize:
26
- Enabled: false
27
-
28
- Metrics/PerceivedComplexity:
29
- Enabled: false
30
-
31
- Metrics/CyclomaticComplexity:
32
- Enabled: false
33
-
34
- Metrics/MethodLength:
35
- Enabled: false
36
-
37
- Metrics/ClassLength:
38
- Enabled: false
39
-
40
- Gemspec/DevelopmentDependencies:
41
- EnforcedStyle: 'gemspec'
1
+ require:
2
+ - standard
3
+ - standard-custom
4
+ - standard-performance
5
+ - rubocop-performance
6
+
7
+ inherit_gem:
8
+ standard: config/base.yml
9
+ standard-custom: config/base.yml
10
+ standard-performance: config/base.yml
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.5
data/Gemfile CHANGED
@@ -1,8 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in graphql-hive.gemspec
8
8
  gemspec
9
+
10
+ group :development do
11
+ gem "bundler", "~> 2"
12
+ gem "debug", ">= 1.0.0"
13
+ gem "rack-test", "~> 2"
14
+ gem "rake", "~> 13"
15
+ gem "rspec", "~> 3"
16
+ gem "sinatra", "~> 2"
17
+ gem "standardrb", "~> 1"
18
+ gem "vcr", "~> 6"
19
+ gem "webmock", "~> 3"
20
+ end
data/Gemfile.lock CHANGED
@@ -1,29 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-hive (0.4.2)
4
+ graphql-hive (0.5.1)
5
5
  graphql (>= 2.3, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ addressable (2.8.7)
11
+ public_suffix (>= 2.0.2, < 7.0)
10
12
  ast (2.4.2)
11
13
  base64 (0.2.0)
14
+ bigdecimal (3.1.8)
15
+ crack (1.0.0)
16
+ bigdecimal
17
+ rexml
18
+ debug (1.9.2)
19
+ irb (~> 1.10)
20
+ reline (>= 0.3.8)
12
21
  diff-lcs (1.5.1)
13
22
  graphql (2.3.7)
14
23
  base64
24
+ hashdiff (1.1.1)
25
+ io-console (0.7.2)
26
+ irb (1.14.1)
27
+ rdoc (>= 4.0.0)
28
+ reline (>= 0.4.2)
15
29
  json (2.7.2)
16
30
  language_server-protocol (3.17.0.3)
17
- parallel (1.25.1)
18
- parser (3.3.3.0)
31
+ lint_roller (1.1.0)
32
+ mustermann (2.0.2)
33
+ ruby2_keywords (~> 0.0.1)
34
+ parallel (1.26.3)
35
+ parser (3.3.5.0)
19
36
  ast (~> 2.4.1)
20
37
  racc
21
- racc (1.8.0)
38
+ psych (5.1.2)
39
+ stringio
40
+ public_suffix (6.0.1)
41
+ racc (1.8.1)
42
+ rack (2.2.10)
43
+ rack-protection (2.2.4)
44
+ rack
45
+ rack-test (2.1.0)
46
+ rack (>= 1.3)
22
47
  rainbow (3.1.1)
23
48
  rake (13.2.1)
49
+ rdoc (6.7.0)
50
+ psych (>= 4.0.0)
24
51
  regexp_parser (2.9.2)
25
- rexml (3.3.1)
26
- strscan
52
+ reline (0.5.10)
53
+ io-console (~> 0.5)
54
+ rexml (3.3.8)
27
55
  rspec (3.13.0)
28
56
  rspec-core (~> 3.13.0)
29
57
  rspec-expectations (~> 3.13.0)
@@ -37,22 +65,52 @@ GEM
37
65
  diff-lcs (>= 1.2.0, < 2.0)
38
66
  rspec-support (~> 3.13.0)
39
67
  rspec-support (3.13.1)
40
- rubocop (1.64.1)
68
+ rubocop (1.65.1)
41
69
  json (~> 2.3)
42
70
  language_server-protocol (>= 3.17.0)
43
71
  parallel (~> 1.10)
44
72
  parser (>= 3.3.0.2)
45
73
  rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.8, < 3.0)
74
+ regexp_parser (>= 2.4, < 3.0)
47
75
  rexml (>= 3.2.5, < 4.0)
48
76
  rubocop-ast (>= 1.31.1, < 2.0)
49
77
  ruby-progressbar (~> 1.7)
50
78
  unicode-display_width (>= 2.4.0, < 3.0)
51
- rubocop-ast (1.31.3)
79
+ rubocop-ast (1.32.3)
52
80
  parser (>= 3.3.1.0)
81
+ rubocop-performance (1.21.1)
82
+ rubocop (>= 1.48.1, < 2.0)
83
+ rubocop-ast (>= 1.31.1, < 2.0)
53
84
  ruby-progressbar (1.13.0)
54
- strscan (3.1.0)
55
- unicode-display_width (2.5.0)
85
+ ruby2_keywords (0.0.5)
86
+ sinatra (2.2.4)
87
+ mustermann (~> 2.0)
88
+ rack (~> 2.2)
89
+ rack-protection (= 2.2.4)
90
+ tilt (~> 2.0)
91
+ standard (1.40.1)
92
+ language_server-protocol (~> 3.17.0.2)
93
+ lint_roller (~> 1.0)
94
+ rubocop (~> 1.65.0)
95
+ standard-custom (~> 1.0.0)
96
+ standard-performance (~> 1.4)
97
+ standard-custom (1.0.2)
98
+ lint_roller (~> 1.0)
99
+ rubocop (~> 1.50)
100
+ standard-performance (1.4.0)
101
+ lint_roller (~> 1.1)
102
+ rubocop-performance (~> 1.21.0)
103
+ standardrb (1.0.1)
104
+ standard
105
+ stringio (3.1.1)
106
+ tilt (2.4.0)
107
+ unicode-display_width (2.6.0)
108
+ vcr (6.3.1)
109
+ base64
110
+ webmock (3.24.0)
111
+ addressable (>= 2.8.0)
112
+ crack (>= 0.3.2)
113
+ hashdiff (>= 0.4.0, < 2.0.0)
56
114
 
57
115
  PLATFORMS
58
116
  arm64-darwin-23
@@ -60,10 +118,15 @@ PLATFORMS
60
118
 
61
119
  DEPENDENCIES
62
120
  bundler (~> 2)
121
+ debug (>= 1.0.0)
63
122
  graphql-hive!
123
+ rack-test (~> 2)
64
124
  rake (~> 13)
65
125
  rspec (~> 3)
66
- rubocop (~> 1)
126
+ sinatra (~> 2)
127
+ standardrb (~> 1)
128
+ vcr (~> 6)
129
+ webmock (~> 3)
67
130
 
68
131
  BUNDLED WITH
69
132
  2.5.15
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # GraphQL Hive: `graphql-ruby` integration
1
+ # GraphQL Hive: `graphql-ruby` integration
2
2
  [![CI Suite](https://github.com/charlypoly/graphql-ruby-hive/actions/workflows/ci.yml/badge.svg)](https://github.com/charlypoly/graphql-ruby-hive/actions)
3
3
  [![Gem Version](https://badge.fury.io/rb/graphql-hive.svg)](https://rubygems.org/gems/graphql-hive)
4
4
 
@@ -146,39 +146,53 @@ class MySchema < GraphQL::Schema
146
146
  use(
147
147
  GraphQL::Hive,
148
148
  {
149
- # mandatory
150
- token: 'YOUR-TOKEN',
151
-
152
- # optional
153
- enabled: true, # enable/disable Hive Client
154
- debug: false, # verbose logs
149
+ # Token is the only required configuration value.
150
+ token: 'YOUR-REGISTRY-TOKEN',
151
+ #
152
+ # The following are optional configuration values.
153
+ #
154
+ # Enable/disable Hive Client.
155
+ enabled: true,
156
+ # Verbose logs.
157
+ debug: false,
158
+ # A custom logger.
155
159
  logger: MyLogger.new,
160
+ # Endpoint and port of the Hive API. Change this if you are using a self-hosted Hive instance.
156
161
  endpoint: 'app.graphql-hive.com',
157
- port: 80,
158
- buffer_size: 50, # forward the operations data to Hive every 50 requests
159
-
160
- collect_usage: true, # report usage to Hive
162
+ port: 80,
163
+ # Number of operations sent to Hive in a batch (AFTER sampling).
164
+ buffer_size: 50,
165
+ # Size of the queue used to send operations to the buffer before sampling.
166
+ queue_size: 1000,
167
+ # Report usage to Hive.
168
+ collect_usage: true,
169
+ # Usage sampling configurations.
161
170
  collect_usage_sampling: {
162
- # optional members of `collect_usage_sampling`
163
- sample_rate: 0.5, # % of operations reported
164
- sampler: proc { |context| context.operation_name.includes?('someQuery') 1 : 0.5 }, # assign custom sampling rates (overrides `sampling rate`)
165
- at_least_once: true, # sample every distinct operation at least once
166
- key_generator: proc { |context| context.operation_name } # assign custom keys to distinguish between distinct operations
167
- }
168
-
169
- report_schema: true, # publish schema to Hive
170
- # mandatory if `report_schema: true`
171
- reporting: {
172
- # mandatory members of `reporting`
171
+ # % of operations recorded.
172
+ sample_rate: 0.5,
173
+ # Custom sampler to assign custom sampling rates.
174
+ sampler: proc { |context| context.operation_name.includes?('someQuery') 1 : 0.5 },
175
+ # Sample every distinct operation at least once.
176
+ at_least_once: true,
177
+ # Assign custom keys to distinguish between distinct operations.
178
+ key_generator: proc { |context| context.operation_name }
179
+ },
180
+ # Publish schema to Hive.
181
+ report_schema: true,
182
+ # Mandatory if `report_schema: true`.
183
+ reporting: {
184
+ # Mandatory members of `reporting`.
173
185
  author: 'Author of the latest change',
174
186
  commit: 'git sha or any identifier',
175
- # optional members of `reporting
187
+ # Optional members of `reporting`.
176
188
  service_name: '',
177
189
  service_url: '',
178
190
  },
179
191
 
180
- # pass an optional proc to client_info to help identify the client (ex: Apollo web app) that performed the query
181
- client_info: proc { |context| { name: context.client_name, version: context.client_version } }
192
+ # Pass an optional proc to client_info to help identify the client (ex: Apollo web app) that performed the query.
193
+ client_info: proc { |context|
194
+ { name: context.client_name, version: context.client_version }
195
+ }
182
196
  }
183
197
  )
184
198
 
@@ -187,16 +201,14 @@ class MySchema < GraphQL::Schema
187
201
  end
188
202
  ```
189
203
 
190
- See default options for the optional parameters [here](https://github.com/charlypoly/graphql-ruby-hive/blob/01407d8fed80912a7006fee503bf2967fa20a79c/lib/graphql-hive.rb#L53).
204
+ See default options for the optional parameters [here](https://github.com/rperryng/graphql-ruby-hive/blob/master/lib/graphql-hive.rb#L31-L41).
191
205
 
192
206
  <br/>
193
207
 
194
- **A note on `buffer_size` and performances**
195
-
196
- The `graphql-hive` usage reporter, responsible for sending the operations data to Hive, is running in a separate `Thread` to avoid any significant impact on your GraphQL API performances.
197
-
198
- The performance overhead (with the default `buffer_size` option) is around 1% and [is constantly evaluated for new PR](https://github.com/charlypoly/graphql-ruby-hive/actions/workflows/benchmark.yml).
199
-
200
- If your GraphQL API has a high RPM, we encourage you to increase the `buffer_size` value.
201
-
202
- However, please note that a higher `buffer_size` value will introduce some peak of increase in memory consumption.
208
+ > [!Important]
209
+ > `buffer_size` and `queue_size` will affect memory consumption.
210
+ >
211
+ > `buffer_size` is the number of operations sent to Hive in a batch after operations have been sampled.
212
+ > `queue_size` is the size of the queue used to send operations to the buffer before sampling.
213
+ > Adjust these values according to your application's memory constraints and throughput.
214
+ > High throughput applications will need a larger `queue_size`.
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require 'rubocop/rake_task'
8
+ require "rubocop/rake_task"
9
9
  RuboCop::RakeTask.new
10
10
 
11
11
  task(default: %i[spec rubocop])
data/graphql-hive.gemspec CHANGED
@@ -1,33 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'graphql-hive/version'
5
+ require "graphql-hive/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'graphql-hive'
9
- spec.version = Graphql::Hive::VERSION
10
- spec.authors = ['Charly POLY']
11
- spec.email = ['cpoly55@gmail.com']
8
+ spec.name = "graphql-hive"
9
+ spec.version = Graphql::Hive::VERSION
10
+ spec.authors = ["Charly POLY"]
11
+ spec.email = ["cpoly55@gmail.com"]
12
12
 
13
- spec.summary = '"GraphQL Hive integration for `graphql-ruby`"'
14
- spec.description = '"Monitor operations, inspect your queries and publish your GraphQL schema with GraphQL Hive"'
15
- spec.homepage = 'https://docs.graphql-hive.com/specs/integrations'
16
- spec.license = 'MIT'
13
+ spec.summary = '"GraphQL Hive integration for `graphql-ruby`"'
14
+ spec.description = '"Monitor operations, inspect your queries and publish your GraphQL schema with GraphQL Hive"'
15
+ spec.homepage = "https://docs.graphql-hive.com/specs/integrations"
16
+ spec.license = "MIT"
17
17
 
18
- spec.metadata = { 'rubygems_mfa_required' => 'true' }
18
+ spec.metadata = {"rubygems_mfa_required" => "true"}
19
19
 
20
- spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
21
21
 
22
- spec.require_paths = ['lib']
23
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ spec.require_paths = ["lib"]
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
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'
28
-
29
- spec.add_development_dependency 'bundler', '~> 2'
30
- spec.add_development_dependency 'rake', '~> 13'
31
- spec.add_development_dependency 'rspec', '~> 3'
32
- spec.add_development_dependency 'rubocop', '~> 1'
27
+ spec.add_dependency "graphql", ">= 2.3", "< 3"
33
28
  end
@@ -73,7 +73,7 @@ module GraphQL
73
73
  end
74
74
 
75
75
  def make_id(*tokens)
76
- tokens.join('.')
76
+ tokens.join(".")
77
77
  end
78
78
  end
79
79
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'net/http'
4
- require 'uri'
3
+ require "net/http"
4
+ require "uri"
5
5
 
6
6
  module GraphQL
7
7
  class Hive < GraphQL::Tracing::PlatformTracing
@@ -14,9 +14,9 @@ module GraphQL
14
14
  def send(path, body, _log_type)
15
15
  uri =
16
16
  URI::HTTP.build(
17
- scheme: @options[:port].to_s == '443' ? 'https' : 'http',
18
- host: @options[:endpoint] || 'app.graphql-hive.com',
19
- port: @options[:port] || '443',
17
+ scheme: (@options[:port].to_s == "443") ? "https" : "http",
18
+ host: @options[:endpoint] || "app.graphql-hive.com",
19
+ port: @options[:port] || "443",
20
20
  path: path
21
21
  )
22
22
 
@@ -26,25 +26,25 @@ module GraphQL
26
26
 
27
27
  @options[:logger].debug(response.inspect)
28
28
  @options[:logger].debug(response.body.inspect)
29
- rescue StandardError => e
29
+ rescue => e
30
30
  @options[:logger].fatal("Failed to send data: #{e}")
31
31
  end
32
32
 
33
33
  def setup_http(uri)
34
34
  http = ::Net::HTTP.new(uri.host, uri.port)
35
- http.use_ssl = @options[:port].to_s == '443'
35
+ http.use_ssl = @options[:port].to_s == "443"
36
36
  http.read_timeout = 2
37
37
  http
38
38
  end
39
39
 
40
40
  def build_request(uri, body)
41
41
  request = Net::HTTP::Post.new(uri.request_uri)
42
- request['Authorization'] = @options[:token]
43
- request['X-Usage-API-Version'] = '2'
44
- request['content-type'] = 'application/json'
45
- request['User-Agent'] = "Hive@#{Graphql::Hive::VERSION}"
46
- request['graphql-client-name'] = 'Hive Ruby Client'
47
- request['graphql-client-version'] = Graphql::Hive::VERSION
42
+ request["Authorization"] = @options[:token]
43
+ request["X-Usage-API-Version"] = "2"
44
+ request["content-type"] = "application/json"
45
+ request["User-Agent"] = "Hive@#{Graphql::Hive::VERSION}"
46
+ request["graphql-client-name"] = "Hive Ruby Client"
47
+ request["graphql-client-version"] = Graphql::Hive::VERSION
48
48
  request.body = JSON.generate(body)
49
49
  request
50
50
  end
@@ -10,12 +10,12 @@ module GraphQL
10
10
  @out.append(str)
11
11
  end
12
12
 
13
- def print_node(node, indent: '')
13
+ def print_node(node, indent: "")
14
14
  case node
15
15
  when Float, Integer
16
- print_string '0'
16
+ print_string "0"
17
17
  when String
18
- print_string ''
18
+ print_string ""
19
19
  else
20
20
  super
21
21
  end
@@ -23,16 +23,16 @@ module GraphQL
23
23
 
24
24
  # from GraphQL::Language::Printer with sort_by name
25
25
  # ignores aliases
26
- def print_field(field, indent: '')
26
+ def print_field(field, indent: "")
27
27
  print_string(indent)
28
28
  print_string(field.name)
29
29
  if field.arguments.any?
30
- print_string('(')
30
+ print_string("(")
31
31
  field.arguments.sort_by(&:name).each_with_index do |a, i|
32
32
  print_argument(a)
33
- print_string(', ') if i < field.arguments.size - 1
33
+ print_string(", ") if i < field.arguments.size - 1
34
34
  end
35
- print_string(')')
35
+ print_string(")")
36
36
  end
37
37
  print_directives(field.directives)
38
38
  print_selections(field.selections, indent: indent)
@@ -43,7 +43,7 @@ module GraphQL
43
43
  end
44
44
 
45
45
  # from GraphQL::Language::Printer with sort_by name
46
- def print_selections(selections, indent: '')
46
+ def print_selections(selections, indent: "")
47
47
  sorted_nodes = selections.sort_by do |s|
48
48
  next s.name if s.respond_to?(:name)
49
49
  next s.type.name if s.respond_to?(:type)
@@ -55,35 +55,35 @@ module GraphQL
55
55
 
56
56
  # from GraphQL::Language::Printer with sort_by name
57
57
  def print_directive(directive)
58
- print_string('@')
58
+ print_string("@")
59
59
  print_string(directive.name)
60
60
 
61
61
  return if directive.arguments.blank?
62
62
 
63
- print_string('(')
63
+ print_string("(")
64
64
  directive.arguments.sort_by(&:name).each_with_index do |a, i|
65
65
  print_argument(a)
66
- print_string(', ') if i < directive.arguments.size - 1
66
+ print_string(", ") if i < directive.arguments.size - 1
67
67
  end
68
- print_string(')')
68
+ print_string(")")
69
69
  end
70
70
 
71
71
  # from GraphQL::Language::Printer with sort_by name
72
- def print_operation_definition(operation_definition, indent: '')
72
+ def print_operation_definition(operation_definition, indent: "")
73
73
  print_string(indent)
74
74
  print_string(operation_definition.operation_type)
75
75
  if operation_definition.name
76
- print_string(' ')
76
+ print_string(" ")
77
77
  print_string(operation_definition.name)
78
78
  end
79
79
 
80
80
  if operation_definition.variables.any?
81
- print_string('(')
81
+ print_string("(")
82
82
  operation_definition.variables.sort_by(&:name).each_with_index do |v, i|
83
83
  print_variable_definition(v)
84
- print_string(', ') if i < operation_definition.variables.size - 1
84
+ print_string(", ") if i < operation_definition.variables.size - 1
85
85
  end
86
- print_string(')')
86
+ print_string(")")
87
87
  end
88
88
 
89
89
  print_directives(operation_definition.directives)
@@ -8,28 +8,28 @@ module GraphQL
8
8
  # backwards compatibility with old `collect_usage_sampling` field
9
9
  if sampling_options.is_a?(Numeric)
10
10
  logger&.warn(
11
- '`collect_usage_sampling` is deprecated for fixed sampling rates, ' \
12
- 'use `collect_usage_sampling: { sample_rate: XX }` instead'
11
+ "`collect_usage_sampling` is deprecated for fixed sampling rates, " \
12
+ "use `collect_usage_sampling: { sample_rate: XX }` instead"
13
13
  )
14
14
  passed_sampling_rate = sampling_options
15
- sampling_options = { sample_rate: passed_sampling_rate }
15
+ sampling_options = {sample_rate: passed_sampling_rate}
16
16
  end
17
17
 
18
18
  sampling_options ||= {}
19
19
 
20
20
  @sampler = if sampling_options[:sampler]
21
- Sampling::DynamicSampler.new(
22
- sampling_options[:sampler],
23
- sampling_options[:at_least_once],
24
- sampling_options[:key_generator]
25
- )
26
- else
27
- Sampling::BasicSampler.new(
28
- sampling_options[:sample_rate],
29
- sampling_options[:at_least_once],
30
- sampling_options[:key_generator]
31
- )
32
- end
21
+ Sampling::DynamicSampler.new(
22
+ sampling_options[:sampler],
23
+ sampling_options[:at_least_once],
24
+ sampling_options[:key_generator]
25
+ )
26
+ else
27
+ Sampling::BasicSampler.new(
28
+ sampling_options[:sample_rate],
29
+ sampling_options[:at_least_once],
30
+ sampling_options[:key_generator]
31
+ )
32
+ end
33
33
  end
34
34
 
35
35
  def sample?(operation)