Class: GraphQL::Stitching::Plan
- Inherits:
-
Object
- Object
- GraphQL::Stitching::Plan
- Defined in:
- lib/graphql/stitching/plan.rb
Overview
Immutable-ish structures representing a query plan. May serialize to/from JSON.
Defined Under Namespace
Classes: Op
Instance Attribute Summary collapse
-
#ops ⇒ Object
readonly
Returns the value of attribute ops.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(ops: []) ⇒ Plan
constructor
A new instance of Plan.
Constructor Details
#initialize(ops: []) ⇒ Plan
Returns a new instance of Plan.
57 58 59 |
# File 'lib/graphql/stitching/plan.rb', line 57 def initialize(ops: []) @ops = ops end |
Instance Attribute Details
#ops ⇒ Object (readonly)
Returns the value of attribute ops.
55 56 57 |
# File 'lib/graphql/stitching/plan.rb', line 55 def ops @ops end |
Class Method Details
.from_json(json) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/graphql/stitching/plan.rb', line 36 def from_json(json) ops = json["ops"] ops = ops.map do |op| Op.new( step: op["step"], after: op["after"], location: op["location"], operation_type: op["operation_type"], selections: op["selections"], variables: op["variables"], path: op["path"], if_type: op["if_type"], resolver: op["resolver"], ) end new(ops: ops) end |
Instance Method Details
#as_json ⇒ Object
61 62 63 |
# File 'lib/graphql/stitching/plan.rb', line 61 def as_json { ops: @ops.map(&:as_json) } end |