Class: GraphQL::SchemaComparator::Changes::DirectiveArgumentTypeChanged

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(directive, old_argument, new_argument) ⇒ DirectiveArgumentTypeChanged

Returns a new instance of DirectiveArgumentTypeChanged.



455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/graphql/schema_comparator/changes.rb', line 455

def initialize(directive, 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

  @directive = directive
  @old_argument = old_argument
  @new_argument = new_argument
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality.



453
454
455
# File 'lib/graphql/schema_comparator/changes.rb', line 453

def criticality
  @criticality
end

#directiveObject (readonly)

Returns the value of attribute directive.



453
454
455
# File 'lib/graphql/schema_comparator/changes.rb', line 453

def directive
  @directive
end

#new_argumentObject (readonly)

Returns the value of attribute new_argument.



453
454
455
# File 'lib/graphql/schema_comparator/changes.rb', line 453

def new_argument
  @new_argument
end

#old_argumentObject (readonly)

Returns the value of attribute old_argument.



453
454
455
# File 'lib/graphql/schema_comparator/changes.rb', line 453

def old_argument
  @old_argument
end

Instance Method Details

#messageObject



469
470
471
472
# File 'lib/graphql/schema_comparator/changes.rb', line 469

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

#pathObject



474
475
476
# File 'lib/graphql/schema_comparator/changes.rb', line 474

def path
  ["@#{directive.graphql_name}", old_argument.graphql_name].join('.')
end