Method: GraphQL::Current.operation_name

Defined in:
lib/graphql/current.rb

.operation_nameString?

Returns Comma-joined operation names for the currently-running Execution::Multiplex. nil if all operations are anonymous.

Returns:

  • (String, nil)

    Comma-joined operation names for the currently-running Execution::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