class GraphQL::Groups::Schema::AggregateType

Public Class Methods

add_fields(fields) click to toggle source
# 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