Sha256: 5c7387a7b91ec575ce7ff712e5541d8226c48f9d8108d97fa87fda73ce21369b

Contents?: true

Size: 472 Bytes

Versions: 2

Compression:

Stored size: 472 Bytes

Contents

class GraphQL::FieldDefiner
  include Singleton

  def build(type:, args: {}, property: nil, desc: "", deprecation_reason: nil)
    resolve = if property.nil?
      -> (o, a, c)  { GraphQL::Query::DEFAULT_RESOLVE }
    else
      -> (object, a, c) { object.send(property) }
    end

    GraphQL::Field.new do |f|
      f.type(type)
      f.arguments(args)
      f.description(desc)
      f.resolve(resolve)
      f.deprecation_reason(deprecation_reason)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql-0.3.0 lib/graph_ql/definition_helpers/field_definer.rb
graphql-0.2.0 lib/graph_ql/types/field_definer.rb