Class: ActiveGraphql::Client::Actions::Action
- Inherits:
-
Object
- Object
- ActiveGraphql::Client::Actions::Action
- Includes:
- VariableDetectable
- Defined in:
- lib/active_graphql/client/actions/action.rb,
lib/active_graphql/client/actions/action/format_inputs.rb,
lib/active_graphql/client/actions/action/format_outputs.rb,
lib/active_graphql/client/actions/action/format_variable_inputs.rb
Overview
Base class for query/mutation action objects
Direct Known Subclasses
Defined Under Namespace
Classes: FormatInputs, FormatOutputs, FormatVariableInputs, InvalidActionError
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#input_attributes ⇒ Object
readonly
Returns the value of attribute input_attributes.
-
#meta_attributes ⇒ Object
readonly
Returns the value of attribute meta_attributes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output_values ⇒ Object
readonly
Returns the value of attribute output_values.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #graphql_variables ⇒ Object
-
#initialize(name:, client:, output_values: [], input_attributes: {}, meta_attributes: {}) ⇒ Action
constructor
A new instance of Action.
- #inspect ⇒ Object
- #meta(new_attributes) ⇒ Object
- #reselect(*array_outputs, **hash_outputs) ⇒ Object
- #response ⇒ Object
- #rewhere(**input_attributes) ⇒ Object
- #select(*array_outputs, **hash_outputs) ⇒ Object (also: #output)
- #to_graphql ⇒ Object
- #where(**extra_input_attributes) ⇒ Object (also: #input)
Methods included from VariableDetectable
#variable_attributes, #variable_value?
Constructor Details
#initialize(name:, client:, output_values: [], input_attributes: {}, meta_attributes: {}) ⇒ Action
Returns a new instance of Action.
21 22 23 24 25 26 27 |
# File 'lib/active_graphql/client/actions/action.rb', line 21 def initialize(name:, client:, output_values: [], input_attributes: {}, meta_attributes: {}) @name = name @output_values = output_values @input_attributes = input_attributes @meta_attributes = @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
17 18 19 |
# File 'lib/active_graphql/client/actions/action.rb', line 17 def client @client end |
#input_attributes ⇒ Object (readonly)
Returns the value of attribute input_attributes.
17 18 19 |
# File 'lib/active_graphql/client/actions/action.rb', line 17 def input_attributes @input_attributes end |
#meta_attributes ⇒ Object (readonly)
Returns the value of attribute meta_attributes.
17 18 19 |
# File 'lib/active_graphql/client/actions/action.rb', line 17 def @meta_attributes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/active_graphql/client/actions/action.rb', line 17 def name @name end |
#output_values ⇒ Object (readonly)
Returns the value of attribute output_values.
17 18 19 |
# File 'lib/active_graphql/client/actions/action.rb', line 17 def output_values @output_values end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/active_graphql/client/actions/action.rb', line 17 def type @type end |
Instance Method Details
#graphql_variables ⇒ Object
78 79 80 |
# File 'lib/active_graphql/client/actions/action.rb', line 78 def graphql_variables variable_attributes(input_attributes) end |
#inspect ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/active_graphql/client/actions/action.rb', line 29 def inspect "#<#{self.class} " \ "name: #{name.inspect}, " \ "input: #{input_attributes.inspect}, " \ "output: #{output_values.inspect}, " \ "meta: #{.inspect}" \ '>' end |
#meta(new_attributes) ⇒ Object
51 52 53 |
# File 'lib/active_graphql/client/actions/action.rb', line 51 def (new_attributes) chain(meta_attributes: .merge(new_attributes)) end |
#reselect(*array_outputs, **hash_outputs) ⇒ Object
55 56 57 58 |
# File 'lib/active_graphql/client/actions/action.rb', line 55 def reselect(*array_outputs, **hash_outputs) outputs = join_array_and_hash(*array_outputs, **hash_outputs) chain(output_values: outputs) end |
#response ⇒ Object
47 48 49 |
# File 'lib/active_graphql/client/actions/action.rb', line 47 def response client.post(self) end |
#rewhere(**input_attributes) ⇒ Object
38 39 40 |
# File 'lib/active_graphql/client/actions/action.rb', line 38 def rewhere(**input_attributes) chain(input_attributes: input_attributes) end |
#select(*array_outputs, **hash_outputs) ⇒ Object Also known as: output
60 61 62 63 |
# File 'lib/active_graphql/client/actions/action.rb', line 60 def select(*array_outputs, **hash_outputs) full_array_outputs = (output_values + array_outputs).uniq reselect(*full_array_outputs, **hash_outputs) end |
#to_graphql ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/active_graphql/client/actions/action.rb', line 66 def to_graphql assert_format <<~TXT #{type}#{wrapped_header formatted_variable_headers} { #{name}#{wrapped_header formatted_inputs} { #{formatted_outputs} } } TXT end |
#where(**extra_input_attributes) ⇒ Object Also known as: input
42 43 44 |
# File 'lib/active_graphql/client/actions/action.rb', line 42 def where(**extra_input_attributes) rewhere(**input_attributes, **extra_input_attributes) end |