class GraphQL::SchemaComparator::Diff::Union

Attributes

new_possible_types[R]
new_type[R]
old_possible_types[R]
old_type[R]

Public Class Methods

new(old_type, new_type) click to toggle source
# 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

Public Instance Methods

diff() click to toggle source
# 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

Private Instance Methods

added_possible_types() click to toggle source
# File lib/graphql/schema_comparator/diff/union.rb, line 32
def added_possible_types
  filter_types(new_possible_types, old_possible_types)
end
filter_types(types, exclude_types) click to toggle source
# File lib/graphql/schema_comparator/diff/union.rb, line 36
def filter_types(types, exclude_types)
  types.select { |type| !exclude_types.map(&:graphql_definition).include?(type.graphql_definition) }
end
removed_possible_types() click to toggle source
# File lib/graphql/schema_comparator/diff/union.rb, line 28
def removed_possible_types
  filter_types(old_possible_types, new_possible_types)
end