Sha256: e1a8750346400974594d47f23e687c56f687c7e6b36747f9f12209c34f237f8a

Contents?: true

Size: 696 Bytes

Versions: 6

Compression:

Stored size: 696 Bytes

Contents

module GraphQL
  module Sugar
    module Define
      module Attribute
        def self.call(type_defn, field_name, type_or_field = nil, desc = nil, **kwargs, &block) # rubocop:disable Metrics/ParameterLists
          model_class = Sugar.get_model_class(type_defn)
          column_name = Sugar.get_column_name(field_name)

          type_or_field ||= kwargs[:type] if !kwargs[:type].nil?
          type_or_field ||= Sugar.get_graphql_type(model_class, column_name)

          kwargs[:property] ||= column_name.to_sym if kwargs[:resolve].nil?

          GraphQL::Define::AssignObjectField.call(type_defn, field_name, type_or_field, desc, **kwargs, &block)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graphql-sugar-0.1.6 lib/graphql/sugar/define/attribute.rb
graphql-sugar-0.1.5 lib/graphql/sugar/define/attribute.rb
graphql-sugar-0.1.4 lib/graphql/sugar/define/attribute.rb
graphql-sugar-0.1.3 lib/graphql/sugar/define/attribute.rb
graphql-sugar-0.1.2 lib/graphql/sugar/define/attribute.rb
graphql-sugar-0.1.1 lib/graphql/sugar/define/attribute.rb