Class: GraphQL::FieldDefiner

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/graph_ql/types/field_definer.rb

Instance Method Summary collapse

Instance Method Details

#build(type:, args: {}, property: nil, desc: "", deprecation_reason: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/graph_ql/types/field_definer.rb', line 4

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