Class: GraphQL::Groups::Schema::AggregateType

Inherits:
Schema::Object
  • Object
show all
Defined in:
lib/graphql/groups/schema/aggregate_type.rb

Class Method Summary collapse

Class Method Details

.add_fields(fields) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/graphql/groups/schema/aggregate_type.rb', line 12

def add_fields(fields)
  fields.each do |attribute|
    resolve_method = "resolve_#{attribute}".to_sym
    field attribute, Float, null: false, resolver_method: resolve_method

    define_method resolve_method do
      object[attribute]
    end
  end
end