Class: GraphQL::Stitching::Plan

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#opsObject (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_jsonObject



61
62
63
# File 'lib/graphql/stitching/plan.rb', line 61

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