Class: GraphQL::SchemaComparator::Changes::FieldTypeChanged

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SafeTypeChange

#safe_change_for_field?, #safe_change_for_input_value?

Methods inherited from AbstractChange

#breaking?, #dangerous?, #non_breaking?

Constructor Details

#initialize(type, old_field, new_field) ⇒ FieldTypeChanged

Returns a new instance of FieldTypeChanged.



365
366
367
368
369
# File 'lib/graphql/schema_comparator/changes.rb', line 365

def initialize(type, old_field, new_field)
  @type = type
  @old_field = old_field
  @new_field = new_field
end

Instance Attribute Details

#new_fieldObject (readonly)

Returns the value of attribute new_field.



363
364
365
# File 'lib/graphql/schema_comparator/changes.rb', line 363

def new_field
  @new_field
end

#old_fieldObject (readonly)

Returns the value of attribute old_field.



363
364
365
# File 'lib/graphql/schema_comparator/changes.rb', line 363

def old_field
  @old_field
end

#typeObject (readonly)

Returns the value of attribute type.



363
364
365
# File 'lib/graphql/schema_comparator/changes.rb', line 363

def type
  @type
end

Instance Method Details

#criticalityObject



375
376
377
378
379
380
381
# File 'lib/graphql/schema_comparator/changes.rb', line 375

def criticality
  if safe_change_for_field?(old_field.type, new_field.type)
    Changes::Criticality.non_breaking
  else
    Changes::Criticality.breaking # TODO - Add reason
  end
end

#messageObject



371
372
373
# File 'lib/graphql/schema_comparator/changes.rb', line 371

def message
  "Field `#{old_field.path}` changed type from `#{old_field.type.to_type_signature}` to `#{new_field.type.to_type_signature}`"
end

#pathObject



383
384
385
# File 'lib/graphql/schema_comparator/changes.rb', line 383

def path
  old_field.path
end