Module: GraphQL::AnyCable

Defined in:
lib/graphql-anycable.rb,
lib/graphql/anycable/stats.rb,
lib/graphql/anycable/config.rb,
lib/graphql/anycable/errors.rb,
lib/graphql/anycable/cleaner.rb,
lib/graphql/anycable/railtie.rb,
lib/graphql/anycable/version.rb

Defined Under Namespace

Modules: Cleaner Classes: ChannelConfigurationError, Config, Railtie, Stats

Constant Summary collapse

VERSION =
"1.3.0"

Class Method Summary collapse

Class Method Details

.configObject



41
42
43
# File 'lib/graphql-anycable.rb', line 41

def config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



45
46
47
# File 'lib/graphql-anycable.rb', line 45

def configure
  yield(config) if block_given?
end

.redisObject



23
24
25
26
# File 'lib/graphql-anycable.rb', line 23

def redis
  warn "Usage of `GraphQL::AnyCable.redis` is deprecated. Instead of `GraphQL::AnyCable.redis.whatever` use `GraphQL::AnyCable.with_redis { |redis| redis.whatever }`"
  @redis ||= with_redis { |conn| conn }
end

.redis=(connector) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/graphql-anycable.rb', line 28

def redis=(connector)
  @redis_connector = if connector.is_a?(::Proc)
    connector
  else
    ->(&block) { block.call connector }
  end
end

.stats(**opts) ⇒ Object



19
20
21
# File 'lib/graphql-anycable.rb', line 19

def stats(**opts)
  Stats.new(**opts).collect
end

.use(schema, **opts) ⇒ Object



15
16
17
# File 'lib/graphql-anycable.rb', line 15

def use(schema, **opts)
  schema.use(GraphQL::Subscriptions::AnyCableSubscriptions, **opts)
end

.with_redis(&block) ⇒ Object



36
37
38
39
# File 'lib/graphql-anycable.rb', line 36

def with_redis(&block)
  @redis_connector || default_redis_connector
  @redis_connector.call(&block)
end