Class: GraphQL::Field
- Inherits:
-
Object
- Object
- GraphQL::Field
- Includes:
- DefinitionHelpers::DefinedByConfig
- Defined in:
- lib/graphql/field.rb
Overview
Fields belong to ObjectTypes and InterfaceTypes.
They’re usually created with the ‘field` helper.
Instance Attribute Summary collapse
-
#arguments(new_arguments = nil) ⇒ Object
Returns the value of attribute arguments.
-
#deprecation_reason ⇒ Object
Returns the value of attribute deprecation_reason.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#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 DefinitionHelpers::DefinedByConfig
Constructor Details
#initialize ⇒ Field
Returns a new instance of Field.
46 47 48 49 |
# File 'lib/graphql/field.rb', line 46 def initialize @arguments = {} @resolve_proc = build_default_resolver end |
Instance Attribute Details
#arguments(new_arguments = nil) ⇒ Object
Returns the value of attribute arguments.
42 43 44 |
# File 'lib/graphql/field.rb', line 42 def arguments @arguments end |
#deprecation_reason ⇒ Object
Returns the value of attribute deprecation_reason.
42 43 44 |
# File 'lib/graphql/field.rb', line 42 def deprecation_reason @deprecation_reason end |
#description ⇒ Object
Returns the value of attribute description.
42 43 44 |
# File 'lib/graphql/field.rb', line 42 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
42 43 44 |
# File 'lib/graphql/field.rb', line 42 def name @name end |
#property ⇒ Object
Returns the value of attribute property.
42 43 44 |
# File 'lib/graphql/field.rb', line 42 def property @property end |
#resolve_proc ⇒ Object (readonly)
Returns the value of attribute resolve_proc.
43 44 45 |
# File 'lib/graphql/field.rb', line 43 def resolve_proc @resolve_proc end |
#type ⇒ Object
Get the return type for this field.
79 80 81 |
# File 'lib/graphql/field.rb', line 79 def type @type end |
Instance Method Details
#resolve(object, arguments, context) ⇒ Object
Get a value for this field
70 71 72 |
# File 'lib/graphql/field.rb', line 70 def resolve(object, arguments, context) @resolve_proc.call(object, arguments, context) end |
#resolve=(resolve_proc) ⇒ Object
74 75 76 |
# File 'lib/graphql/field.rb', line 74 def resolve=(resolve_proc) @resolve_proc = resolve_proc || build_default_resolver end |
#to_s ⇒ Object
92 93 94 |
# File 'lib/graphql/field.rb', line 92 def to_s "<Field: #{name || "not-named"}>" end |