graphql-anycable 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e8f296cdfe805ab7eb4ea8247b3880b785ba1314c3c2ef25d3ac316765714b5
4
- data.tar.gz: d010e06e309c4724a111ebb5cff503678bf53b0ba8039f438ecd86892073ef7d
3
+ metadata.gz: 2ff33e113bf80dad3da7cab49606e37f7b3b69783ce4e8b2bb0466bf3e636881
4
+ data.tar.gz: 6c9c58824c29cf9d35e7dc82c70c32b8e398c5482847f888133de5e9fb5ebdb9
5
5
  SHA512:
6
- metadata.gz: c84765a3b9461f431da8e3ad4a31fdc50e28836d9b331e04af7374676002bb9b02c78d6e18512b1e776a8d13fa431232c5c019b059497ccdee6953adecbde53c
7
- data.tar.gz: 3a741fbaaf27eea28bd0a1885cee1e7ac1b24e8bb8a270537751465fa78e1f73f1ef1a3ca1538670e7d90503292dc5e05d8511a8f81861144ee999c6a9f30e25
6
+ metadata.gz: 11f689864709223c38a4441b2546f285389ff7d32b694cc983ebda2cc3e829b271686eb25e2d2ca3df3bafa36d2b12ec61b6cb043c28b1b11b98683efb21c2d8
7
+ data.tar.gz: d973bb2885f9991b3be3fb13f0c8fec2c7815b67b993ced900d53812d0b661433f3db99cf193ee2b827c57ab59ea1d7111c34d6c8a8cf1923f8b01dfedebc34a
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 1.0.1 - 2021-04-16
11
+
12
+ ### Added
13
+
14
+ - Guard check for presence of ActionCable channel instance in the GraphQL execution context.
15
+
16
+ This allows to detect wrong configuration (user forgot to pass channel into context) or wrong usage (subscription query was sent via HTTP request, not via WebSocket channel) of the library and provides clear error message to gem users.
17
+
10
18
  ## 1.0.0 - 2021-04-01
11
19
 
12
20
  ### Added
@@ -0,0 +1,20 @@
1
+ module GraphQL
2
+ module AnyCable
3
+ # This error is thrown when ActionCable channel wasn't provided to subscription implementation.
4
+ # Typical cases:
5
+ # 1. application developer forgot to pass ActionCable channel into context
6
+ # 2. subscription query was sent via usual HTTP request, not websockets as intended
7
+ class ChannelConfigurationError < ::RuntimeError
8
+ def initialize(msg = nil)
9
+ super(msg || <<~DEFAULT_MESSAGE)
10
+ ActionCable channel wasn't provided in the context for GraphQL query execution!
11
+
12
+ This can occur in the following cases:
13
+ 1. ActionCable channel instance wasn't passed into GraphQL execution context in the channel's execute method.
14
+ See https://github.com/anycable/graphql-anycable#usage
15
+ 2. Subscription query was sent via usual HTTP request, not via WebSocket as intended
16
+ DEFAULT_MESSAGE
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module AnyCable
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "anycable"
4
4
  require "graphql/subscriptions"
5
+ require "graphql/anycable/errors"
5
6
 
6
7
  # rubocop: disable Metrics/AbcSize, Metrics/LineLength, Metrics/MethodLength
7
8
 
@@ -140,6 +141,8 @@ module GraphQL
140
141
  subscription_id = context.delete(:subscription_id) || build_id
141
142
  channel = context.delete(:channel)
142
143
 
144
+ raise GraphQL::AnyCable::ChannelConfigurationError unless channel
145
+
143
146
  events.each do |event|
144
147
  channel.stream_from(SUBSCRIPTIONS_PREFIX + event.fingerprint)
145
148
  end
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.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-01 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anycable
@@ -155,6 +155,7 @@ files:
155
155
  - lib/graphql/anycable.rb
156
156
  - lib/graphql/anycable/cleaner.rb
157
157
  - lib/graphql/anycable/config.rb
158
+ - lib/graphql/anycable/errors.rb
158
159
  - lib/graphql/anycable/railtie.rb
159
160
  - lib/graphql/anycable/tasks/clean_expired_subscriptions.rake
160
161
  - lib/graphql/anycable/version.rb
@@ -178,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
179
  - !ruby/object:Gem::Version
179
180
  version: '0'
180
181
  requirements: []
181
- rubygems_version: 3.1.4
182
+ rubygems_version: 3.1.6
182
183
  signing_key:
183
184
  specification_version: 4
184
185
  summary: A drop-in replacement for GraphQL ActionCable subscriptions for AnyCable.