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 ⇒ Object
Returns the value of attribute after.
-
#boundary ⇒ Object
Returns the value of attribute boundary.
-
#if_type ⇒ Object
readonly
Returns the value of attribute if_type.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#operation_type ⇒ Object
readonly
Returns the value of attribute operation_type.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#parent_type ⇒ Object
readonly
Returns the value of attribute parent_type.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#selections ⇒ Object
Returns the value of attribute selections.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(location:, parent_type:, order:, after: nil, operation_type: "query", selections: [], variables: [], path: [], if_type: nil, boundary: nil) ⇒ PlannerOperation
constructor
A new instance of PlannerOperation.
- #selection_set ⇒ Object
- #to_h ⇒ Object
- #variable_set ⇒ Object
Constructor Details
#initialize(location:, parent_type:, order:, after: nil, operation_type: "query", selections: [], variables: [], path: [], if_type: nil, 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( location:, parent_type:, order:, after: nil, operation_type: "query", selections: [], variables: [], path: [], if_type: nil, boundary: nil ) @location = location @parent_type = parent_type @order = order @after = after @operation_type = operation_type @selections = selections @variables = variables @path = path @if_type = if_type @boundary = boundary end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
9 10 11 |
# File 'lib/graphql/stitching/planner_operation.rb', line 9 def after @after 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 |
#if_type ⇒ Object (readonly)
Returns the value of attribute if_type.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def if_type @if_type 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 |
#order ⇒ Object (readonly)
Returns the value of attribute order.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def order @order 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 |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/graphql/stitching/planner_operation.rb', line 8 def path @path 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 |
#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 59 60 |
# File 'lib/graphql/stitching/planner_operation.rb', line 46 def to_h data = { "order" => @order, "after" => @after, "location" => @location, "operation_type" => @operation_type, "selections" => selection_set, "variables" => variable_set, "path" => @path, } data["if_type"] = @if_type if @if_type data["boundary"] = @boundary if @boundary data 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 |