Class: GraphQL::SchemaComparator::Diff::Union

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/schema_comparator/diff/union.rb

Instance Method Summary collapse

Constructor Details

#initialize(old_type, new_type) ⇒ Union


5
6
7
8
9
10
11
# File 'lib/graphql/schema_comparator/diff/union.rb', line 5

def initialize(old_type, new_type)
  @old_type = old_type
  @new_type = new_type

  @old_possible_types = old_type.possible_types
  @new_possible_types = new_type.possible_types
end

Instance Method Details

#diffObject


13
14
15
16
17
18
19
20
21
22
# File 'lib/graphql/schema_comparator/diff/union.rb', line 13

def diff
  changes = []
  changes += removed_possible_types.map do |removed|
    Changes::UnionMemberRemoved.new(new_type, removed)
  end
  changes += added_possible_types.map do |added|
    Changes::UnionMemberAdded.new(new_type, added)
  end
  changes
end