Class: GraphQL::Stitching::PlannerOperation
- Inherits:
-
Object
- Object
- GraphQL::Stitching::PlannerOperation
- Defined in:
- lib/graphql/stitching/planner_operation.rb
Constant Summary collapse
- LANGUAGE_PRINTER =
GraphQL::Language::Printer.new
Instance Attribute Summary collapse
-
#after_key ⇒ Object
Returns the value of attribute after_key.
-
#boundary ⇒ Object
Returns the value of attribute boundary.
-
#insertion_path ⇒ Object
readonly
Returns the value of attribute insertion_path.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#operation_type ⇒ Object
readonly
Returns the value of attribute operation_type.
-
#parent_type ⇒ Object
readonly
Returns the value of attribute parent_type.
-
#selections ⇒ Object
Returns the value of attribute selections.
-
#type_condition ⇒ Object
readonly
Returns the value of attribute type_condition.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(key:, location:, parent_type:, operation_type: "query", insertion_path: [], type_condition: nil, after_key: nil, selections: [], variables: [], boundary: nil) ⇒ PlannerOperation
constructor
A new instance of PlannerOperation.
- #selection_set ⇒ Object
- #to_h ⇒ Object
- #variable_set ⇒ Object
Constructor Details
#initialize(key:, location:, parent_type:, operation_type: "query", insertion_path: [], type_condition: nil, after_key: nil, selections: [], variables: [], boundary: nil) ⇒ PlannerOperation
Returns a new instance of PlannerOperation.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/graphql/stitching/planner_operation.rb', line 11 def initialize( key:, location:, parent_type:, operation_type: "query", insertion_path: [], type_condition: nil, after_key: nil, selections: [], variables: [], boundary: nil ) @key = key @after_key = after_key @location = location @parent_type = parent_type @operation_type = operation_type @insertion_path = insertion_path @type_condition = type_condition @selections = selections @variables = variables @boundary = boundary end |
Instance Attribute Details
#after_key ⇒ Object
Returns the value of attribute after_key.
9 10 11 |
# File 'lib/graphql/stitching/planner_operation.rb', line 9 def after_key @after_key end |
#boundary ⇒ Object
Returns the value of attribute boundary.
9 10 11 |
# File 'lib/graphql/stitching/planner_operation.rb', line 9 def boundary @boundary end |
#insertion_path ⇒ Object (readonly)
Returns the value of attribute insertion_path.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def insertion_path @insertion_path end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def key @key end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def location @location end |
#operation_type ⇒ Object (readonly)
Returns the value of attribute operation_type.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def operation_type @operation_type end |
#parent_type ⇒ Object (readonly)
Returns the value of attribute parent_type.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def parent_type @parent_type end |
#selections ⇒ Object
Returns the value of attribute selections.
9 10 11 |
# File 'lib/graphql/stitching/planner_operation.rb', line 9 def selections @selections end |
#type_condition ⇒ Object (readonly)
Returns the value of attribute type_condition.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def type_condition @type_condition end |
#variables ⇒ Object
Returns the value of attribute variables.
9 10 11 |
# File 'lib/graphql/stitching/planner_operation.rb', line 9 def variables @variables end |
Instance Method Details
#selection_set ⇒ Object
35 36 37 38 |
# File 'lib/graphql/stitching/planner_operation.rb', line 35 def selection_set op = GraphQL::Language::Nodes::OperationDefinition.new(selections: @selections) LANGUAGE_PRINTER.print(op).gsub!(/\s+/, " ").strip! end |
#to_h ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/graphql/stitching/planner_operation.rb', line 46 def to_h { "key" => @key, "after_key" => @after_key, "location" => @location, "operation_type" => @operation_type, "insertion_path" => @insertion_path, "type_condition" => @type_condition, "selections" => selection_set, "variables" => variable_set, "boundary" => @boundary, } end |
#variable_set ⇒ Object
40 41 42 43 44 |
# File 'lib/graphql/stitching/planner_operation.rb', line 40 def variable_set @variables.each_with_object({}) do |(variable_name, value_type), memo| memo[variable_name] = LANGUAGE_PRINTER.print(value_type) end end |