Sha256: a7dc886deb7d0927a28add24f2828d3a8694c9c7d128612da20d03dbd285499e

Contents?: true

Size: 590 Bytes

Versions: 8

Compression:

Stored size: 590 Bytes

Contents

# frozen_string_literal: true

require 'graphql'

module GraphQL
  module Groups
    module Schema
      class AggregateType < GraphQL::Schema::Object
        alias aggregate object

        class << self
          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
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-groups-0.2.3 lib/graphql/groups/schema/aggregate_type.rb
graphql-groups-0.2.2 lib/graphql/groups/schema/aggregate_type.rb
graphql-groups-0.2.1 lib/graphql/groups/schema/aggregate_type.rb
graphql-groups-0.2.0 lib/graphql/groups/schema/aggregate_type.rb
graphql-groups-0.1.4 lib/graphql/groups/schema/aggregate_type.rb
graphql-groups-0.1.3 lib/graphql/groups/schema/aggregate_type.rb
graphql-groups-0.1.2 lib/graphql/groups/schema/aggregate_type.rb
graphql-groups-0.1.1 lib/graphql/groups/schema/aggregate_type.rb