Skip to content

Commit

Permalink
Delay the deprecation warning of use_client_provided_uniq_id (#26)
Browse files Browse the repository at this point in the history
When setting the `use_client_provided_uniq_id` to false through Ruby
configuration code the deprecation warning was still issued:

```ruby
GraphQL::AnyCable.config.use_client_provided_uniq_id = false

# or...

GraphQL::AnyCable.configure do |config|
  config.use_client_provided_uniq_id = false
end
```

This happened because the deprecation warning was issued through an
`on_load` callback that is invoked when the `GraphQL::AnyCable.config`
is initialised. At that time, Anyway is getting settings through sources
like ENV variables, but the Ruby configuration code is invoked
**afterwards**. But we prefer having this setting in Ruby code, not
in an ENV or a YAML setting file.
  • Loading branch information
gsamokovarov authored and Envek committed Jul 28, 2022
1 parent 0ed613d commit 704b1f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 0 additions & 8 deletions lib/graphql/anycable/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ class Config < Anyway::Config
attr_config use_redis_object_on_cleanup: true
attr_config handle_legacy_subscriptions: false
attr_config use_client_provided_uniq_id: true

on_load do
next unless use_client_provided_uniq_id?

warn "[Deprecated] Using client provided channel uniq IDs could lead to unexpected behaviour, " \
" please, set GraphQL::AnyCable.config.use_client_provided_uniq_id = false or GRAPHQL_ANYCABLE_USE_CLIENT_PROVIDED_UNIQ_ID=false, " \
" and update the `#unsubscribed` callback code according to the latest docs."
end
end
end
end
8 changes: 8 additions & 0 deletions lib/graphql/anycable/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class Railtie < ::Rails::Railtie
path = File.expand_path(__dir__)
Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
end

config.after_initialize do
if GraphQL::AnyCable.config.use_client_provided_uniq_id?
warn "[Deprecated] Using client provided channel uniq IDs could lead to unexpected behaviour, " \
"please, set GraphQL::AnyCable.config.use_client_provided_uniq_id = false or GRAPHQL_ANYCABLE_USE_CLIENT_PROVIDED_UNIQ_ID=false, " \
"and update the `#unsubscribed` callback code according to the latest docs."
end
end
end
end
end

0 comments on commit 704b1f3

Please sign in to comment.