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


284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/graphql/schema_comparator/changes.rb', line 284

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


282
283
284
# File 'lib/graphql/schema_comparator/changes.rb', line 282

def criticality
  @criticality
end

#directiveObject (readonly)

Returns the value of attribute directive


282
283
284
# File 'lib/graphql/schema_comparator/changes.rb', line 282

def directive
  @directive
end

#new_argumentObject (readonly)

Returns the value of attribute new_argument


282
283
284
# File 'lib/graphql/schema_comparator/changes.rb', line 282

def new_argument
  @new_argument
end

#old_argumentObject (readonly)

Returns the value of attribute old_argument


282
283
284
# File 'lib/graphql/schema_comparator/changes.rb', line 282

def old_argument
  @old_argument
end

Instance Method Details

#messageObject


298
299
300
301
# File 'lib/graphql/schema_comparator/changes.rb', line 298

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