Class: GraphQL::SchemaComparator::Changes::DirectiveArgumentDefaultChanged

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractChange

#breaking?, #dangerous?, #non_breaking?

Constructor Details

#initialize(directive, old_argument, new_argument) ⇒ DirectiveArgumentDefaultChanged

Returns a new instance of DirectiveArgumentDefaultChanged.



535
536
537
538
539
540
541
542
543
# File 'lib/graphql/schema_comparator/changes.rb', line 535

def initialize(directive, old_argument, new_argument)
  @criticality = Changes::Criticality.dangerous(
    reason: "Changing the default value for an argument may change the runtime " \
      "behaviour of a field if it was never provided."
  )
  @directive = directive
  @old_argument = old_argument
  @new_argument = new_argument
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality.



533
534
535
# File 'lib/graphql/schema_comparator/changes.rb', line 533

def criticality
  @criticality
end

#directiveObject (readonly)

Returns the value of attribute directive.



533
534
535
# File 'lib/graphql/schema_comparator/changes.rb', line 533

def directive
  @directive
end

#new_argumentObject (readonly)

Returns the value of attribute new_argument.



533
534
535
# File 'lib/graphql/schema_comparator/changes.rb', line 533

def new_argument
  @new_argument
end

#old_argumentObject (readonly)

Returns the value of attribute old_argument.



533
534
535
# File 'lib/graphql/schema_comparator/changes.rb', line 533

def old_argument
  @old_argument
end

Instance Method Details

#messageObject



545
546
547
548
549
550
551
552
# File 'lib/graphql/schema_comparator/changes.rb', line 545

def message
  if old_argument.default_value?
    "Default value for argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}` changed"\
      " from `#{old_argument.default_value}` to `#{new_argument.default_value}`"
  else
    "Default value `#{new_argument.default_value}` was added to argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}`"
  end
end

#pathObject



554
555
556
# File 'lib/graphql/schema_comparator/changes.rb', line 554

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