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.
Constant Summary collapse
- DEFAULT_RESOLVE =
-> (o, a, c) { GraphQL::Query::DEFAULT_RESOLVE }
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.
-
#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.
36 37 38 39 |
# File 'lib/graphql/field.rb', line 36 def initialize @arguments = {} @resolve_proc = DEFAULT_RESOLVE end |
Instance Attribute Details
#arguments(new_arguments = nil) ⇒ Object
Returns the value of attribute arguments.
33 34 35 |
# File 'lib/graphql/field.rb', line 33 def arguments @arguments end |
#deprecation_reason ⇒ Object
Returns the value of attribute deprecation_reason.
33 34 35 |
# File 'lib/graphql/field.rb', line 33 def deprecation_reason @deprecation_reason end |
#description ⇒ Object
Returns the value of attribute description.
33 34 35 |
# File 'lib/graphql/field.rb', line 33 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
33 34 35 |
# File 'lib/graphql/field.rb', line 33 def name @name end |
#type ⇒ Object
Get the return type for this field.
69 70 71 |
# File 'lib/graphql/field.rb', line 69 def type @type end |
Instance Method Details
#resolve(object, arguments, context) ⇒ Object
Get a value for this field
60 61 62 |
# File 'lib/graphql/field.rb', line 60 def resolve(object, arguments, context) @resolve_proc.call(object, arguments, context) end |
#resolve=(resolve_proc) ⇒ Object
64 65 66 |
# File 'lib/graphql/field.rb', line 64 def resolve=(resolve_proc) @resolve_proc = resolve_proc || DEFAULT_RESOLVE end |
#to_s ⇒ Object
77 78 79 |
# File 'lib/graphql/field.rb', line 77 def to_s "<Field: #{name || "not-named"}>" end |