class GraphQL::SchemaComparator::Diff::InputObject
Attributes
new_fields[R]
new_type[R]
old_fields[R]
old_type[R]
Public Class Methods
new(old_type, new_type)
click to toggle source
# File lib/graphql/schema_comparator/diff/input_object.rb, line 5 def initialize(old_type, new_type) @old_type = old_type @new_type = new_type @old_fields = old_type.arguments @new_fields = new_type.arguments end
Public Instance Methods
diff()
click to toggle source
# File lib/graphql/schema_comparator/diff/input_object.rb, line 13 def diff changes = [] changes += removed_fields.map { |field| Changes::InputFieldRemoved.new(old_type, field) } changes += added_fields.map { |field| Changes::InputFieldAdded.new(new_type, field) } each_common_field do |old_field, new_field| # TODO: Add Directive Stuff changes += InputField.new(old_type, new_type, old_field, new_field).diff end changes end
Private Instance Methods
added_fields()
click to toggle source
# File lib/graphql/schema_comparator/diff/input_object.rb, line 45 def added_fields new_fields.values.select { |field| !old_fields[field.name] } end
each_common_field(&block)
click to toggle source
# File lib/graphql/schema_comparator/diff/input_object.rb, line 31 def each_common_field(&block) intersection = old_fields.keys & new_fields.keys intersection.each do |common_field| old_field = old_type.arguments[common_field] new_field = new_type.arguments[common_field] block.call(old_field, new_field) end end
removed_fields()
click to toggle source
# File lib/graphql/schema_comparator/diff/input_object.rb, line 41 def removed_fields old_fields.values.select { |field| !new_fields[field.name] } end