Class: GraphQL::SchemaComparator::Changes::FieldArgumentTypeChanged

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, field, old_argument, new_argument) ⇒ FieldArgumentTypeChanged

Returns a new instance of FieldArgumentTypeChanged.



423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/graphql/schema_comparator/changes.rb', line 423

def initialize(type, field, old_argument, new_argument)
  if safe_change_for_input_value?(old_argument.type, new_argument.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(
      reason: "Changing the type of a field's argument can cause existing queries that use this argument to error."
    )
  end

  @type = type
  @field = field
  @old_argument = old_argument
  @new_argument = new_argument
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality.



421
422
423
# File 'lib/graphql/schema_comparator/changes.rb', line 421

def criticality
  @criticality
end

#fieldObject (readonly)

Returns the value of attribute field.



421
422
423
# File 'lib/graphql/schema_comparator/changes.rb', line 421

def field
  @field
end

#new_argumentObject (readonly)

Returns the value of attribute new_argument.



421
422
423
# File 'lib/graphql/schema_comparator/changes.rb', line 421

def new_argument
  @new_argument
end

#old_argumentObject (readonly)

Returns the value of attribute old_argument.



421
422
423
# File 'lib/graphql/schema_comparator/changes.rb', line 421

def old_argument
  @old_argument
end

#typeObject (readonly)

Returns the value of attribute type.



421
422
423
# File 'lib/graphql/schema_comparator/changes.rb', line 421

def type
  @type
end

Instance Method Details

#messageObject



440
441
442
443
# File 'lib/graphql/schema_comparator/changes.rb', line 440

def message
  "Type for argument `#{new_argument.graphql_name}` on field `#{field.path}` changed"\
    " from `#{old_argument.type.to_type_signature}` to `#{new_argument.type.to_type_signature}`"
end

#pathObject



445
446
447
# File 'lib/graphql/schema_comparator/changes.rb', line 445

def path
  old_argument.path
end