graphql-hive 0.2.0 → 0.3.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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +41 -2
- data/RELEASING.md +10 -0
- data/k6/graphql-api/Gemfile.lock +1 -1
- data/lib/graphql-hive/printer.rb +7 -1
- data/lib/graphql-hive/usage_reporter.rb +32 -11
- data/lib/graphql-hive/version.rb +1 -1
- data/lib/graphql-hive.rb +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddb07c0967f9d855e35fe6fc0e4de8d150296a696bddfa04b03a51871d22ec5d
|
4
|
+
data.tar.gz: 3a061660f99486014a748b457a1a573b62b87f7126dd2ee11eb2ed0a51d73153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da040838d105fef9cf821681045aa247733ddc6d53da991fb8fb9d64950a713846cee35e645ef6b8db70f40b955b05d2446367ed5625b152ef66c59917d9b0ea
|
7
|
+
data.tar.gz: bf78194e3f7bd1cb405794060e693e80f0fa1cd111c1d776b45f19f2c2a288b0d266fe40d61e8fba66afe37209c7ec45e42882b221f7b5cf6e6ba87738a854b0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql-hive (0.
|
4
|
+
graphql-hive (0.3.1)
|
5
5
|
graphql (~> 2.0.9)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
diff-lcs (1.5.0)
|
12
|
-
graphql (2.0.
|
12
|
+
graphql (2.0.16)
|
13
13
|
parallel (1.22.1)
|
14
14
|
parser (3.1.2.0)
|
15
15
|
ast (~> 2.4.1)
|
data/README.md
CHANGED
@@ -64,6 +64,44 @@ If you only want to use the operations monitoring, replace the `reporting` optio
|
|
64
64
|
|
65
65
|
<br/>
|
66
66
|
|
67
|
+
## 3. (Optional) Configure Lifecycle Hooks
|
68
|
+
|
69
|
+
Calling these hooks are situational - it's likely that you may not need to call
|
70
|
+
them at all!
|
71
|
+
|
72
|
+
### `on_start`
|
73
|
+
|
74
|
+
Call this hook if you are running `GraphQL::Hive` in a process that `fork`s
|
75
|
+
itself.
|
76
|
+
|
77
|
+
example: `puma` web server running in (["clustered
|
78
|
+
mode"](https://github.com/puma/puma/tree/6d8b728b42a61bcf3c1e4c698c9165a45e6071e8#clustered-mode))
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# config/puma.rb
|
82
|
+
preload_app!
|
83
|
+
|
84
|
+
on_worker_boot do
|
85
|
+
GraphQL::Hive.instance.on_start
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
### `on_exit`
|
90
|
+
|
91
|
+
If your GraphQL API process is shut down non-gracefully but has a shutdown hook
|
92
|
+
to call into, call `on_worker_exit`.
|
93
|
+
|
94
|
+
`puma` example:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
# config/puma.rb
|
98
|
+
|
99
|
+
on_worker_shutdown do
|
100
|
+
GraphQL::Hive.instance.on_exit
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
<br />
|
67
105
|
|
68
106
|
**You are all set! 🚀**
|
69
107
|
|
@@ -74,7 +112,7 @@ When deploying or starting up your GraphQL API, `graphql-hive` will immediately:
|
|
74
112
|
|
75
113
|
<br/>
|
76
114
|
|
77
|
-
##
|
115
|
+
## 4. See how your GraphQL API is operating
|
78
116
|
|
79
117
|
You should now see operations information (RPM, error rate, queries performed) on your [GraphQL Hive dashboard](https://app.graphql-hive.com/):
|
80
118
|
|
@@ -86,7 +124,7 @@ You should now see operations information (RPM, error rate, queries performed) o
|
|
86
124
|
<br/>
|
87
125
|
|
88
126
|
|
89
|
-
##
|
127
|
+
## 5. Going further: use the Hive Github app
|
90
128
|
|
91
129
|
Stay on top of your GraphQL Schema changes by installing the Hive Github Application and enabling Slack notifications about breaking changes:
|
92
130
|
|
@@ -117,6 +155,7 @@ class MySchema < GraphQL::Schema
|
|
117
155
|
endpoint: 'app.graphql-hive.com', # optional
|
118
156
|
port: 80, # optional
|
119
157
|
buffer_size: 50, # forward the operations data to Hive every 50 requests
|
158
|
+
collect_usage_sampling: 1.0,
|
120
159
|
reporting: { # mandatory if `report_schema: true`
|
121
160
|
# mandatory member of `reporting`
|
122
161
|
author: 'Author of the latest change',
|
data/RELEASING.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
## Releasing `graphql-hive` on RubyGems
|
2
|
+
|
3
|
+
|
4
|
+
1. Ensure dependencies are properly installed: `bundle`
|
5
|
+
1. Ensure the is working as expected: `bundle exec rspec`
|
6
|
+
1. **Make sure to manually bump the version in `lib/graphql-hive/version.rb`**
|
7
|
+
1. Build the gem: `gem build graphql-hive`
|
8
|
+
1. A new file should have been created, ex: `graphql-hive-0.3.0.gem`
|
9
|
+
1. Then, login to RubyGems: `gem login`
|
10
|
+
1. And publish the new version: `gem publish <path_to_gem_file>` (ex: `gem publish graphql-hive-0.3.0.gem`)
|
data/k6/graphql-api/Gemfile.lock
CHANGED
data/lib/graphql-hive/printer.rb
CHANGED
@@ -33,7 +33,13 @@ module GraphQL
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def print_selections(selections, indent: '')
|
36
|
-
|
36
|
+
sorted_nodes = selections.sort_by do |s|
|
37
|
+
next s.name if s.respond_to?(:name)
|
38
|
+
next s.type.name if s.respond_to?(:type)
|
39
|
+
|
40
|
+
raise "don't know how to sort selection node: #{s.inspect}"
|
41
|
+
end
|
42
|
+
super(sorted_nodes, indent: indent)
|
37
43
|
end
|
38
44
|
|
39
45
|
def print_directive(directive)
|
@@ -27,6 +27,31 @@ module GraphQL
|
|
27
27
|
|
28
28
|
@options_mutex = Mutex.new
|
29
29
|
@queue = Queue.new
|
30
|
+
|
31
|
+
start_thread
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_operation(operation)
|
35
|
+
@queue.push(operation)
|
36
|
+
end
|
37
|
+
|
38
|
+
def on_exit
|
39
|
+
@queue.close
|
40
|
+
@thread.join
|
41
|
+
end
|
42
|
+
|
43
|
+
def on_start
|
44
|
+
start_thread
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def start_thread
|
50
|
+
if @thread&.alive?
|
51
|
+
@options[:logger].warn('Tried to start operations flushing thread but it was already alive')
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
30
55
|
@thread = Thread.new do
|
31
56
|
buffer = []
|
32
57
|
while (operation = @queue.pop(false))
|
@@ -44,20 +69,16 @@ module GraphQL
|
|
44
69
|
@options[:logger].debug('shuting down with buffer, sending!')
|
45
70
|
process_operations(buffer)
|
46
71
|
end
|
47
|
-
|
48
|
-
|
72
|
+
rescue StandardError => e
|
73
|
+
# ensure configured logger receives exception as well in setups where STDERR might not be
|
74
|
+
# monitored.
|
75
|
+
@options[:logger].error('GraphQL Hive usage collection thread terminating')
|
76
|
+
@options[:logger].error(e)
|
49
77
|
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
def on_exit
|
55
|
-
@queue.close
|
56
|
-
@thread.join
|
78
|
+
raise e
|
79
|
+
end
|
57
80
|
end
|
58
81
|
|
59
|
-
private
|
60
|
-
|
61
82
|
def process_operations(operations)
|
62
83
|
report = {
|
63
84
|
size: 0,
|
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.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- Gemfile.lock
|
98
98
|
- LICENSE
|
99
99
|
- README.md
|
100
|
+
- RELEASING.md
|
100
101
|
- Rakefile
|
101
102
|
- cover.png
|
102
103
|
- examples/simple-api/Gemfile
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
145
|
+
rubygems_version: 3.3.7
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: '"GraphQL Hive integration for `graphql-ruby`"'
|