Class: GraphQL::SchemaComparator::Diff::InputField

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

Instance Method Summary collapse

Constructor Details

#initialize(old_type, new_type, old_field, new_field) ⇒ InputField

Returns a new instance of InputField.



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

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

  @old_field = old_field
  @new_field = new_field
end

Instance Method Details

#diffObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/graphql/schema_comparator/diff/input_field.rb', line 13

def diff
  changes = []

  if old_field.description != new_field.description
    changes << Changes::InputFieldDescriptionChanged.new(old_type, old_field, new_field)
  end

  if old_field.default_value != new_field.default_value
    changes << Changes::InputFieldDefaultChanged.new(old_type, old_field, new_field)
  end

  if old_field.type.to_type_signature != new_field.type.to_type_signature
    changes << Changes::InputFieldTypeChanged.new(old_type, old_field, new_field)
  end

  # TODO: directives

  changes
end