Class: GQL::Executor
- Inherits:
-
Object
- Object
- GQL::Executor
- Defined in:
- lib/gql/executor.rb
Instance Attribute Summary collapse
-
#ast_root ⇒ Object
readonly
Returns the value of attribute ast_root.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #execute(context = {}, vars = {}) ⇒ Object
-
#initialize(ast_query) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(ast_query) ⇒ Executor
Returns a new instance of Executor.
5 6 7 8 |
# File 'lib/gql/executor.rb', line 5 def initialize(ast_query) @ast_root = ast_query.root @variables = ast_query.variables end |
Instance Attribute Details
#ast_root ⇒ Object (readonly)
Returns the value of attribute ast_root.
3 4 5 |
# File 'lib/gql/executor.rb', line 3 def ast_root @ast_root end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
3 4 5 |
# File 'lib/gql/executor.rb', line 3 def variables @variables end |
Instance Method Details
#execute(context = {}, vars = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gql/executor.rb', line 10 def execute(context = {}, vars = {}) field_class = GQL.root_class raise Errors::RootClassNotSet if field_class.nil? variables.update vars target = GQL.root_target_proc.call(context) field = Registry.fetch(field_class).new(ast_root, target, variables, context) field.value end |