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


258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/graphql/schema_comparator/changes.rb', line 258

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
  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


256
257
258
# File 'lib/graphql/schema_comparator/changes.rb', line 256

def criticality
  @criticality
end

#fieldObject (readonly)

Returns the value of attribute field


256
257
258
# File 'lib/graphql/schema_comparator/changes.rb', line 256

def field
  @field
end

#new_argumentObject (readonly)

Returns the value of attribute new_argument


256
257
258
# File 'lib/graphql/schema_comparator/changes.rb', line 256

def new_argument
  @new_argument
end

#old_argumentObject (readonly)

Returns the value of attribute old_argument


256
257
258
# File 'lib/graphql/schema_comparator/changes.rb', line 256

def old_argument
  @old_argument
end

#typeObject (readonly)

Returns the value of attribute type


256
257
258
# File 'lib/graphql/schema_comparator/changes.rb', line 256

def type
  @type
end

Instance Method Details

#messageObject


273
274
275
276
# File 'lib/graphql/schema_comparator/changes.rb', line 273

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