Class: GraphQL::Field
- Inherits:
-
Object
- Object
- GraphQL::Field
- Includes:
- Define::InstanceDefinable
- Defined in:
- lib/graphql/field.rb
Overview
Fields belong to ObjectTypes and InterfaceTypes.
They’re usually created with the ‘field` helper. If you create it by hand, make sure #name is a String.
Instance Attribute Summary collapse
-
#arguments ⇒ Hash<String, GraphQL::Argument>
Map String argument names to their Argument implementations.
-
#deprecation_reason ⇒ Object
Returns the value of attribute deprecation_reason.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ String
The name of this field on its ObjectType (or InterfaceType).
-
#property ⇒ Object
Returns the value of attribute property.
-
#resolve_proc ⇒ Object
readonly
Returns the value of attribute resolve_proc.
-
#type ⇒ Object
Get the return type for this field.
Instance Method Summary collapse
-
#initialize ⇒ Field
constructor
A new instance of Field.
-
#resolve(object, arguments, context) ⇒ Object
Get a value for this field.
- #resolve=(resolve_proc) ⇒ Object
- #to_s ⇒ Object
Methods included from Define::InstanceDefinable
Constructor Details
#initialize ⇒ Field
Returns a new instance of Field.
54 55 56 57 |
# File 'lib/graphql/field.rb', line 54 def initialize @arguments = {} @resolve_proc = build_default_resolver end |
Instance Attribute Details
#arguments ⇒ Hash<String, GraphQL::Argument>
Returns Map String argument names to their Argument implementations.
52 53 54 |
# File 'lib/graphql/field.rb', line 52 def arguments @arguments end |
#deprecation_reason ⇒ Object
Returns the value of attribute deprecation_reason.
45 46 47 |
# File 'lib/graphql/field.rb', line 45 def deprecation_reason @deprecation_reason end |
#description ⇒ Object
Returns the value of attribute description.
45 46 47 |
# File 'lib/graphql/field.rb', line 45 def description @description end |
#name ⇒ String
Returns The name of this field on its ObjectType (or InterfaceType).
49 50 51 |
# File 'lib/graphql/field.rb', line 49 def name @name end |
#property ⇒ Object
Returns the value of attribute property.
45 46 47 |
# File 'lib/graphql/field.rb', line 45 def property @property end |
#resolve_proc ⇒ Object (readonly)
Returns the value of attribute resolve_proc.
46 47 48 |
# File 'lib/graphql/field.rb', line 46 def resolve_proc @resolve_proc end |
#type ⇒ Object
Get the return type for this field.
75 76 77 |
# File 'lib/graphql/field.rb', line 75 def type @type end |
Instance Method Details
#resolve(object, arguments, context) ⇒ Object
Get a value for this field
66 67 68 |
# File 'lib/graphql/field.rb', line 66 def resolve(object, arguments, context) @resolve_proc.call(object, arguments, context) end |
#resolve=(resolve_proc) ⇒ Object
70 71 72 |
# File 'lib/graphql/field.rb', line 70 def resolve=(resolve_proc) @resolve_proc = resolve_proc || build_default_resolver end |
#to_s ⇒ Object
100 101 102 |
# File 'lib/graphql/field.rb', line 100 def to_s "<Field: #{name || "not-named"}>" end |