Class: GraphQL::Language::OperationDefinition
- Inherits:
-
Struct
- Object
- Struct
- GraphQL::Language::OperationDefinition
- Defined in:
- lib/graphql/language/operation_definition.rb
Instance Attribute Summary collapse
-
#directives ⇒ Object
Returns the value of attribute directives.
-
#name ⇒ Object
Returns the value of attribute name.
-
#selection_set ⇒ Object
Returns the value of attribute selection_set.
-
#type ⇒ Object
Returns the value of attribute type.
-
#variable_definitions ⇒ Object
Returns the value of attribute variable_definitions.
Instance Method Summary collapse
- #evaluate(context) ⇒ Object
- #execute(context) ⇒ Object
- #execute_serially(context) ⇒ Object
- #materialize_variables(schema, params) ⇒ Object
Instance Attribute Details
#directives ⇒ Object
Returns the value of attribute directives
3 4 5 |
# File 'lib/graphql/language/operation_definition.rb', line 3 def directives @directives end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/graphql/language/operation_definition.rb', line 3 def name @name end |
#selection_set ⇒ Object
Returns the value of attribute selection_set
3 4 5 |
# File 'lib/graphql/language/operation_definition.rb', line 3 def selection_set @selection_set end |
#type ⇒ Object
Returns the value of attribute type
3 4 5 |
# File 'lib/graphql/language/operation_definition.rb', line 3 def type @type end |
#variable_definitions ⇒ Object
Returns the value of attribute variable_definitions
3 4 5 |
# File 'lib/graphql/language/operation_definition.rb', line 3 def variable_definitions @variable_definitions end |
Instance Method Details
#evaluate(context) ⇒ Object
6 7 8 9 |
# File 'lib/graphql/language/operation_definition.rb', line 6 def evaluate(context) context[:variables] = materialize_variables(context[:schema], context[:params]) type == 'mutation' ? execute_serially(context) : execute(context) end |
#execute(context) ⇒ Object
12 13 14 |
# File 'lib/graphql/language/operation_definition.rb', line 12 def execute(context) selection_set.evaluate(context, context[:schema].query_type, context[:root]) end |
#execute_serially(context) ⇒ Object
17 18 19 |
# File 'lib/graphql/language/operation_definition.rb', line 17 def execute_serially(context) raise "Not implemented. Yet." end |
#materialize_variables(schema, params) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/graphql/language/operation_definition.rb', line 22 def materialize_variables(schema, params) variable_definitions.reduce({}) do |memo, variable_definition| name = variable_definition.variable.name.to_sym memo[name] = variable_definition.materialize(schema, params[name]) memo end end |