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

Returns a new instance of FieldArgumentDefaultChanged.



484
485
486
487
488
489
490
491
492
493
# File 'lib/graphql/schema_comparator/changes.rb', line 484

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.



482
483
484
# File 'lib/graphql/schema_comparator/changes.rb', line 482

def criticality
  @criticality
end

#fieldObject (readonly)

Returns the value of attribute field.



482
483
484
# File 'lib/graphql/schema_comparator/changes.rb', line 482

def field
  @field
end

#new_argumentObject (readonly)

Returns the value of attribute new_argument.



482
483
484
# File 'lib/graphql/schema_comparator/changes.rb', line 482

def new_argument
  @new_argument
end

#old_argumentObject (readonly)

Returns the value of attribute old_argument.



482
483
484
# File 'lib/graphql/schema_comparator/changes.rb', line 482

def old_argument
  @old_argument
end

#typeObject (readonly)

Returns the value of attribute type.



482
483
484
# File 'lib/graphql/schema_comparator/changes.rb', line 482

def type
  @type
end

Instance Method Details

#messageObject



495
496
497
498
499
500
501
502
# File 'lib/graphql/schema_comparator/changes.rb', line 495

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

#pathObject



504
505
506
# File 'lib/graphql/schema_comparator/changes.rb', line 504

def path
  old_argument.path
end