Class: GraphQL::SchemaComparator::Changes::FieldArgumentDefaultChanged

Inherits:
AbstractChange
  • Object
show all
Defined in:
lib/graphql/schema_comparator/changes.rb

Overview

Dangerous Changes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractChange

#breaking?, #dangerous?, #non_breaking?

Constructor Details

#initialize(type, field, old_argument, new_argument) ⇒ FieldArgumentDefaultChanged



414
415
416
417
418
419
420
421
422
423
# File 'lib/graphql/schema_comparator/changes.rb', line 414

def initialize(type, field, old_argument, new_argument)
  @type = type
  @field = field
  @old_argument = old_argument
  @new_argument = new_argument
  @criticality = Changes::Criticality.dangerous(
    reason: "Changing the default value for an argument may change the runtime " \
      "behaviour of a field if it was never provided."
  )
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality.



412
413
414
# File 'lib/graphql/schema_comparator/changes.rb', line 412

def criticality
  @criticality
end

#fieldObject (readonly)

Returns the value of attribute field.



412
413
414
# File 'lib/graphql/schema_comparator/changes.rb', line 412

def field
  @field
end

#new_argumentObject (readonly)

Returns the value of attribute new_argument.



412
413
414
# File 'lib/graphql/schema_comparator/changes.rb', line 412

def new_argument
  @new_argument
end

#old_argumentObject (readonly)

Returns the value of attribute old_argument.



412
413
414
# File 'lib/graphql/schema_comparator/changes.rb', line 412

def old_argument
  @old_argument
end

#typeObject (readonly)

Returns the value of attribute type.



412
413
414
# File 'lib/graphql/schema_comparator/changes.rb', line 412

def type
  @type
end

Instance Method Details

#messageObject



425
426
427
428
429
430
431
432
# File 'lib/graphql/schema_comparator/changes.rb', line 425

def message
  if old_argument.default_value.nil?
    "Default value `#{new_argument.default_value}` was added to argument `#{new_argument.name}` on field `#{type.name}.#{field.name}`"
  else
    "Default value for argument `#{new_argument.name}` on field `#{type.name}.#{field.name}` changed"\
      " from `#{old_argument.default_value}` to `#{new_argument.default_value}`"
  end
end

#pathObject



434
435
436
# File 'lib/graphql/schema_comparator/changes.rb', line 434

def path
  [type.name, field.name, old_argument.name].join('.')
end