Module: Rails::GraphQL::Helpers::WithFields::ClassMethods

Defined in:
lib/rails/graphql/helpers/with_fields.rb

Instance Method Summary collapse

Instance Method Details

#fields(initialize = nil) ⇒ Object

Return the list of fields, only initialize when explicitly told



23
24
25
26
27
28
# File 'lib/rails/graphql/helpers/with_fields.rb', line 23

def fields(initialize = nil)
  return @fields if defined?(@fields)
  return unless initialize

  @fields = Concurrent::Map.new
end

#fields?Boolean

Check if there are any fields defined



31
32
33
# File 'lib/rails/graphql/helpers/with_fields.rb', line 31

def fields?
  defined?(@fields) && @fields.present?
end

#inherited(subclass) ⇒ Object



16
17
18
19
20
# File 'lib/rails/graphql/helpers/with_fields.rb', line 16

def inherited(subclass)
  super if defined? super
  return unless defined?(@fields)
  fields.each_value(&subclass.method(:proxy_field))
end