Module: GraphQL::Current
- Defined in:
- lib/graphql/current.rb
Overview
This module exposes Fiber-level runtime information.
It won’t work across unrelated fibers, although it will work in child Fibers.
Class Method Summary collapse
-
.dataloader_source_class ⇒ Class?
The currently-running Dataloader::Source class, if there is one.
-
.field ⇒ GraphQL::Field?
The currently-running field, if there is one.
-
.operation_name ⇒ String?
Comma-joined operation names for the currently-running Multiplex.
Class Method Details
.dataloader_source_class ⇒ Class?
Returns The currently-running Dataloader::Source class, if there is one.
48 49 50 |
# File 'lib/graphql/current.rb', line 48 def self.dataloader_source_class Fiber[:__graphql_current_dataloader_source]&.class end |
.field ⇒ GraphQL::Field?
Returns The currently-running field, if there is one.
43 44 45 |
# File 'lib/graphql/current.rb', line 43 def self.field Thread.current[:__graphql_runtime_info]&.values&.first&.current_field end |
.operation_name ⇒ String?
Returns Comma-joined operation names for the currently-running Multiplex. nil
if all operations are anonymous.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/graphql/current.rb', line 26 def self.operation_name if (m = Fiber[:__graphql_current_multiplex]) m.context[:__graphql_current_operation_name] ||= begin names = m.queries.map { |q| q.selected_operation_name } if names.all?(&:nil?) nil else names.join(",") end end else nil end end |