graphql-anycable 1.1.1 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +9 -14
- data/CHANGELOG.md +19 -0
- data/Gemfile +1 -1
- data/README.md +36 -3
- data/graphql-anycable.gemspec +1 -1
- data/lib/graphql/anycable/config.rb +0 -8
- data/lib/graphql/anycable/railtie.rb +8 -0
- data/lib/graphql/anycable/version.rb +1 -1
- data/lib/graphql/subscriptions/anycable_subscriptions.rb +16 -16
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eacc1ccd4d1c59606ade3479520714b0aab25b2107b84d5147cc47c49a692d7
|
4
|
+
data.tar.gz: e1f4d1342578f7f0f0068ed7047758fc1a358441028407d790da2cc09967fc50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5c875158053244e4c7d49e5886b771f9ef0a70180b3ed61e5083698ad00bf2ed2cbc62eeca93effaa35a0d034822b4da3b46504619057d5435e9b398145914a
|
7
|
+
data.tar.gz: b1675532c18609d4bae817292e5604e51ac84d6a327ee84618b3463d0b3a7139f777ece788c503a0226d7c7a184b60950827c687c7cc96c2f3b3dc9d100cde96
|
data/.github/workflows/test.yml
CHANGED
@@ -10,33 +10,30 @@ on:
|
|
10
10
|
|
11
11
|
jobs:
|
12
12
|
test:
|
13
|
-
name: "GraphQL-Ruby ${{ matrix.graphql }}
|
13
|
+
name: "GraphQL-Ruby ${{ matrix.graphql }} on Ruby ${{ matrix.ruby }} (use_client_id: ${{ matrix.client_id }})"
|
14
14
|
runs-on: ubuntu-latest
|
15
15
|
strategy:
|
16
16
|
fail-fast: false
|
17
17
|
matrix:
|
18
18
|
include:
|
19
|
+
- ruby: "3.1"
|
20
|
+
graphql: '~> 2.0.0'
|
21
|
+
client_id: 'false'
|
22
|
+
anycable_rails: '~> 1.3'
|
19
23
|
- ruby: "3.0"
|
20
|
-
graphql: '~> 1.
|
21
|
-
anycable: '~> 1.1.0'
|
24
|
+
graphql: '~> 1.13.0'
|
22
25
|
client_id: 'false'
|
23
|
-
|
26
|
+
anycable_rails: '~> 1.2.0'
|
24
27
|
- ruby: 2.7
|
25
28
|
graphql: '~> 1.12.0'
|
26
|
-
anycable: '~> 1.1.0'
|
27
|
-
client_id: 'false'
|
28
|
-
interpreter: yes
|
29
|
-
- ruby: 2.6
|
30
|
-
graphql: '~> 1.11.0'
|
31
|
-
anycable: '~> 1.0.0'
|
32
29
|
client_id: 'true'
|
33
|
-
|
30
|
+
anycable_rails: '~> 1.1.0'
|
34
31
|
container:
|
35
32
|
image: ruby:${{ matrix.ruby }}
|
36
33
|
env:
|
37
34
|
CI: true
|
38
35
|
GRAPHQL_RUBY_VERSION: ${{ matrix.graphql }}
|
39
|
-
|
36
|
+
ANYCABLE_RAILS_VERSION: ${{ matrix.anycable_rails }}
|
40
37
|
GRAPHQL_ANYCABLE_USE_CLIENT_PROVIDED_UNIQ_ID: ${{ matrix.client_id }}
|
41
38
|
steps:
|
42
39
|
- uses: actions/checkout@v2
|
@@ -55,6 +52,4 @@ jobs:
|
|
55
52
|
bundle install
|
56
53
|
bundle update
|
57
54
|
- name: Run RSpec
|
58
|
-
env:
|
59
|
-
GRAPHQL_RUBY_INTERPRETER: ${{ matrix.interpreter }}
|
60
55
|
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
7
7
|
|
8
8
|
## Unreleased
|
9
9
|
|
10
|
+
## 1.1.4 - 2022-07-28
|
11
|
+
|
12
|
+
- Fix deprecation warning about using client-side channel ids shown even if deprecated functionality was disabled in application code (not via config file or environment variable). [@gsamokovarov] ([#26](https://github.com/anycable/graphql-anycable/pull/26))
|
13
|
+
|
14
|
+
However, now deprecation warning won't be shown if graphql-anycable is used not in Ruby on Rails application.
|
15
|
+
|
16
|
+
## 1.1.3 - 2022-03-11
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- Allow using graphql-anycable with GraphQL-Ruby 2.x (it seem to be already compatible). [@Envek]
|
21
|
+
|
22
|
+
## 1.1.2 - 2022-03-11
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- AnyCable 1.3.0 compatibility. [@palkan] [#21](https://github.com/anycable/graphql-anycable/pull/21)
|
27
|
+
- Redis.rb 5.0 compatibility. [@palkan] [#21](https://github.com/anycable/graphql-anycable/pull/21)
|
28
|
+
|
10
29
|
## 1.1.1 - 2021-12-06
|
11
30
|
|
12
31
|
### Fixed
|
data/Gemfile
CHANGED
@@ -9,7 +9,7 @@ gemspec
|
|
9
9
|
|
10
10
|
gem "graphql", ENV.fetch("GRAPHQL_RUBY_VERSION", "~> 1.12")
|
11
11
|
gem "anycable", ENV.fetch("ANYCABLE_VERSION", "~> 1.0")
|
12
|
-
gem "anycable-rails", ENV.fetch("
|
12
|
+
gem "anycable-rails", ENV.fetch("ANYCABLE_RAILS_VERSION", "~> 1.2")
|
13
13
|
|
14
14
|
group :development, :test do
|
15
15
|
gem "pry"
|
data/README.md
CHANGED
@@ -111,8 +111,8 @@ By default all fields are marked as _not safe for broadcasting_. If a subscripti
|
|
111
111
|
|
112
112
|
```ruby
|
113
113
|
class MySchema < GraphQL::Schema
|
114
|
-
use GraphQL::Execution::Interpreter # Required for graphql-ruby before 1.12.
|
115
|
-
use GraphQL::Analysis::AST
|
114
|
+
use GraphQL::Execution::Interpreter # Required for graphql-ruby before 1.12. Remove it when upgrading to 2.0
|
115
|
+
use GraphQL::Analysis::AST # Required for graphql-ruby before 1.12. Remove it when upgrading to 2.0
|
116
116
|
use GraphQL::AnyCable, broadcast: true, default_broadcastable: true
|
117
117
|
|
118
118
|
subscription SubscriptionType
|
@@ -144,7 +144,7 @@ GraphQL-AnyCable uses [anyway_config] to configure itself. There are several pos
|
|
144
144
|
GRAPHQL_ANYCABLE_USE_CLIENT_PROVIDED_UNIQ_ID=false
|
145
145
|
```
|
146
146
|
|
147
|
-
2. YAML configuration files:
|
147
|
+
2. YAML configuration files (note that this is `config/graphql_anycable.yml`, *not* `config/anycable.yml`):
|
148
148
|
|
149
149
|
```yaml
|
150
150
|
# config/graphql_anycable.yml
|
@@ -215,6 +215,39 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
215
215
|
|
216
216
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
217
217
|
|
218
|
+
### Releasing new versions
|
219
|
+
|
220
|
+
1. Bump version number in `lib/graphql/anycable/version.rb`
|
221
|
+
|
222
|
+
In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(AfterCommitEverywhere::VERSION).to_s`
|
223
|
+
|
224
|
+
2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
|
225
|
+
|
226
|
+
3. Make a commit:
|
227
|
+
|
228
|
+
```sh
|
229
|
+
git add lib/graphql/anycable/version.rb CHANGELOG.md
|
230
|
+
version=$(ruby -r ./lib/graphql/anycable/version.rb -e "puts Gem::Version.new(GraphQL::AnyCable::VERSION)")
|
231
|
+
git commit --message="${version}: " --edit
|
232
|
+
```
|
233
|
+
|
234
|
+
4. Create annotated tag:
|
235
|
+
|
236
|
+
```sh
|
237
|
+
git tag v${version} --annotate --message="${version}: " --edit --sign
|
238
|
+
```
|
239
|
+
|
240
|
+
5. Fill version name into subject line and (optionally) some description (list of changes will be taken from `CHANGELOG.md` and appended automatically)
|
241
|
+
|
242
|
+
6. Push it:
|
243
|
+
|
244
|
+
```sh
|
245
|
+
git push --follow-tags
|
246
|
+
```
|
247
|
+
|
248
|
+
7. GitHub Actions will create a new release, build and push gem into [rubygems.org](https://rubygems.org)! You're done!
|
249
|
+
|
250
|
+
|
218
251
|
## Contributing
|
219
252
|
|
220
253
|
Bug reports and pull requests are welcome on GitHub at https://github.com/Envek/graphql-anycable.
|
data/graphql-anycable.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_dependency "anycable", "~> 1.0"
|
30
30
|
spec.add_dependency "anyway_config", ">= 1.3", "< 3"
|
31
|
-
spec.add_dependency "graphql", "
|
31
|
+
spec.add_dependency "graphql", ">= 1.11", "< 3"
|
32
32
|
spec.add_dependency "redis", ">= 4.2.0"
|
33
33
|
|
34
34
|
spec.add_development_dependency "anycable-rails"
|
@@ -12,14 +12,6 @@ module GraphQL
|
|
12
12
|
attr_config use_redis_object_on_cleanup: true
|
13
13
|
attr_config handle_legacy_subscriptions: false
|
14
14
|
attr_config use_client_provided_uniq_id: true
|
15
|
-
|
16
|
-
on_load do
|
17
|
-
next unless use_client_provided_uniq_id?
|
18
|
-
|
19
|
-
warn "[Deprecated] Using client provided channel uniq IDs could lead to unexpected behaviour, " \
|
20
|
-
" please, set GraphQL::AnyCable.config.use_client_provided_uniq_id = false or GRAPHQL_ANYCABLE_USE_CLIENT_PROVIDED_UNIQ_ID=false, " \
|
21
|
-
" and update the `#unsubscribed` callback code according to the latest docs."
|
22
|
-
end
|
23
15
|
end
|
24
16
|
end
|
25
17
|
end
|
@@ -9,6 +9,14 @@ module GraphQL
|
|
9
9
|
path = File.expand_path(__dir__)
|
10
10
|
Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
|
11
11
|
end
|
12
|
+
|
13
|
+
config.after_initialize do
|
14
|
+
if GraphQL::AnyCable.config.use_client_provided_uniq_id?
|
15
|
+
warn "[Deprecated] Using client provided channel uniq IDs could lead to unexpected behaviour, " \
|
16
|
+
"please, set GraphQL::AnyCable.config.use_client_provided_uniq_id = false or GRAPHQL_ANYCABLE_USE_CLIENT_PROVIDED_UNIQ_ID=false, " \
|
17
|
+
"and update the `#unsubscribed` callback code according to the latest docs."
|
18
|
+
end
|
19
|
+
end
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
@@ -79,9 +79,9 @@ module GraphQL
|
|
79
79
|
return if fingerprints.empty?
|
80
80
|
|
81
81
|
fingerprint_subscription_ids = Hash[fingerprints.zip(
|
82
|
-
redis.pipelined do
|
82
|
+
redis.pipelined do |pipeline|
|
83
83
|
fingerprints.map do |fingerprint|
|
84
|
-
|
84
|
+
pipeline.smembers(SUBSCRIPTIONS_PREFIX + fingerprint)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
)]
|
@@ -160,16 +160,16 @@ module GraphQL
|
|
160
160
|
events: events.map { |e| [e.topic, e.fingerprint] }.to_h.to_json,
|
161
161
|
}
|
162
162
|
|
163
|
-
redis.multi do
|
164
|
-
|
165
|
-
|
163
|
+
redis.multi do |pipeline|
|
164
|
+
pipeline.sadd(CHANNEL_PREFIX + channel_uniq_id, subscription_id)
|
165
|
+
pipeline.mapped_hmset(SUBSCRIPTION_PREFIX + subscription_id, data)
|
166
166
|
events.each do |event|
|
167
|
-
|
168
|
-
|
167
|
+
pipeline.zincrby(FINGERPRINTS_PREFIX + event.topic, 1, event.fingerprint)
|
168
|
+
pipeline.sadd(SUBSCRIPTIONS_PREFIX + event.fingerprint, subscription_id)
|
169
169
|
end
|
170
170
|
next unless config.subscription_expiration_seconds
|
171
|
-
|
172
|
-
|
171
|
+
pipeline.expire(CHANNEL_PREFIX + channel_uniq_id, config.subscription_expiration_seconds)
|
172
|
+
pipeline.expire(SUBSCRIPTION_PREFIX + subscription_id, config.subscription_expiration_seconds)
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -191,19 +191,19 @@ module GraphQL
|
|
191
191
|
events = redis.hget(SUBSCRIPTION_PREFIX + subscription_id, :events)
|
192
192
|
events = events ? JSON.parse(events) : {}
|
193
193
|
fingerprint_subscriptions = {}
|
194
|
-
redis.pipelined do
|
194
|
+
redis.pipelined do |pipeline|
|
195
195
|
events.each do |topic, fingerprint|
|
196
|
-
|
197
|
-
score =
|
196
|
+
pipeline.srem(SUBSCRIPTIONS_PREFIX + fingerprint, subscription_id)
|
197
|
+
score = pipeline.zincrby(FINGERPRINTS_PREFIX + topic, -1, fingerprint)
|
198
198
|
fingerprint_subscriptions[FINGERPRINTS_PREFIX + topic] = score
|
199
199
|
end
|
200
200
|
# Delete subscription itself
|
201
|
-
|
201
|
+
pipeline.del(SUBSCRIPTION_PREFIX + subscription_id)
|
202
202
|
end
|
203
203
|
# Clean up fingerprints that doesn't have any subscriptions left
|
204
|
-
redis.pipelined do
|
204
|
+
redis.pipelined do |pipeline|
|
205
205
|
fingerprint_subscriptions.each do |key, score|
|
206
|
-
|
206
|
+
pipeline.zremrangebyscore(key, '-inf', '0') if score.value.zero?
|
207
207
|
end
|
208
208
|
end
|
209
209
|
delete_legacy_subscription(subscription_id)
|
@@ -252,7 +252,7 @@ module GraphQL
|
|
252
252
|
end
|
253
253
|
|
254
254
|
def write_subscription_id(channel, val)
|
255
|
-
channel.connection.
|
255
|
+
channel.connection.anycable_socket.istate["sid"] = val
|
256
256
|
channel.instance_variable_set(:@__sid__, val)
|
257
257
|
end
|
258
258
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-anycable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anycable
|
@@ -48,16 +48,22 @@ dependencies:
|
|
48
48
|
name: graphql
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.11'
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '3'
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
|
-
- - "
|
61
|
+
- - ">="
|
59
62
|
- !ruby/object:Gem::Version
|
60
63
|
version: '1.11'
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '3'
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: redis
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|