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, type, serially = false) ⇒ 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 10 11 12 13 |
# File 'lib/graphql/language/operation_definition.rb', line 6 def evaluate(context) context[:variables] = materialize_variables(context[:schema], context[:params]) arguments = [ type == 'mutation' ? context[:schema].mutation_type : context[:schema].query_type, type == 'mutation' ] execute(context, *arguments) end |
#execute(context, type, serially = false) ⇒ Object
16 17 18 |
# File 'lib/graphql/language/operation_definition.rb', line 16 def execute(context, type, serially = false) selection_set.evaluate(context, type, context[:root], serially: serially) end |
#materialize_variables(schema, params) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/graphql/language/operation_definition.rb', line 21 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 |