Class: GraphQL::Stitching::Plan

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/stitching/plan.rb

Overview

Immutable structures representing a query plan. May serialize to/from JSON.

Defined Under Namespace

Classes: Op

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ops: []) ⇒ Plan

Returns a new instance of Plan.



90
91
92
# File 'lib/graphql/stitching/plan.rb', line 90

def initialize(ops: [])
  @ops = ops
end

Instance Attribute Details

#opsObject (readonly)

Returns the value of attribute ops.



88
89
90
# File 'lib/graphql/stitching/plan.rb', line 88

def ops
  @ops
end

Class Method Details

.from_json(json) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/graphql/stitching/plan.rb', line 69

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_jsonObject



94
95
96
# File 'lib/graphql/stitching/plan.rb', line 94

def as_json
  { ops: @ops.map(&:as_json) }
end