Class: GraphQL::SchemaComparator::Diff::Argument

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

Instance Method Summary collapse

Constructor Details

#initialize(type, field, old_arg, new_arg) ⇒ Argument

Returns a new instance of Argument.



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

def initialize(type, field, old_arg, new_arg)
  @type = type
  @field = field

  @old_arg = old_arg
  @new_arg = new_arg
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/argument.rb', line 13

def diff
  changes = []

  if old_arg.description != new_arg.description
    changes << Changes::FieldArgumentDescriptionChanged.new(type, field, old_arg, new_arg)
  end

  if old_arg.default_value != new_arg.default_value
    changes << Changes::FieldArgumentDefaultChanged.new(type, field, old_arg, new_arg)
  end

  if old_arg.type.to_type_signature != new_arg.type.to_type_signature
    changes << Changes::FieldArgumentTypeChanged.new(type, field, old_arg, new_arg)
  end

  # TODO directives

  changes
end