Class: GraphQL::SchemaComparator::Changes::InputFieldTypeChanged

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(input_type, old_input_field, new_input_field) ⇒ InputFieldTypeChanged

Returns a new instance of InputFieldTypeChanged


234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/graphql/schema_comparator/changes.rb', line 234

def initialize(input_type, old_input_field, new_input_field)
  if safe_change_for_input_value?(old_input_field.type, new_input_field.type)
    @criticality = Changes::Criticality.non_breaking(
      reason: "Changing an input field from non-null to null is considered non-breaking"
    )
  else
    @criticality = Changes::Criticality.breaking
  end

  @input_type = input_type
  @old_input_field = old_input_field
  @new_input_field = new_input_field
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality


232
233
234
# File 'lib/graphql/schema_comparator/changes.rb', line 232

def criticality
  @criticality
end

#input_typeObject (readonly)

Returns the value of attribute input_type


232
233
234
# File 'lib/graphql/schema_comparator/changes.rb', line 232

def input_type
  @input_type
end

#new_input_fieldObject (readonly)

Returns the value of attribute new_input_field


232
233
234
# File 'lib/graphql/schema_comparator/changes.rb', line 232

def new_input_field
  @new_input_field
end

#old_input_fieldObject (readonly)

Returns the value of attribute old_input_field


232
233
234
# File 'lib/graphql/schema_comparator/changes.rb', line 232

def old_input_field
  @old_input_field
end

Instance Method Details

#messageObject


248
249
250
# File 'lib/graphql/schema_comparator/changes.rb', line 248

def message
  "Input field `#{input_type}.#{old_input_field.name}` changed type from `#{old_input_field.type}` to `#{new_input_field.type}`"
end