Class: GraphQL::FieldDefiner
- Inherits:
-
Object
- Object
- GraphQL::FieldDefiner
- Defined in:
- lib/graphql/field_definer.rb
Overview
Every Node class has a FieldDefiner instance that enables the ‘field.something` API.
Instance Attribute Summary collapse
-
#owner_class ⇒ Object
readonly
Returns the value of attribute owner_class.
Instance Method Summary collapse
-
#initialize(owner_class) ⇒ FieldDefiner
constructor
A new instance of FieldDefiner.
-
#method_missing(method_name, *args, &block) ⇒ Object
‘method_name` is used as a field type and looked up against SCHEMA.
Constructor Details
#initialize(owner_class) ⇒ FieldDefiner
Returns a new instance of FieldDefiner.
5 6 7 |
# File 'lib/graphql/field_definer.rb', line 5 def initialize(owner_class) @owner_class = owner_class end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/graphql/field_definer.rb', line 11 def method_missing(method_name, *args, &block) type = GraphQL::SCHEMA.get_field(method_name) if type.present? create_field(args[0], type: type, description: args[1]) else super end end |
Instance Attribute Details
#owner_class ⇒ Object (readonly)
Returns the value of attribute owner_class.
4 5 6 |
# File 'lib/graphql/field_definer.rb', line 4 def owner_class @owner_class end |