Class: GraphQL::SchemaComparator::Changes::InputFieldAdded

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

Overview

Mostly Non-Breaking Changes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractChange

#breaking?, #dangerous?, #non_breaking?

Constructor Details

#initialize(input_object_type, field) ⇒ InputFieldAdded

Returns a new instance of InputFieldAdded.



633
634
635
636
637
638
639
640
641
642
# File 'lib/graphql/schema_comparator/changes.rb', line 633

def initialize(input_object_type, field)
  @criticality = if field.type.non_null? && !field.default_value?
    Changes::Criticality.breaking(reason: "Adding a non-null input field without a default value to an existing input type will cause existing queries that use this input type to error because they will not provide a value for this new field.")
  else
    Changes::Criticality.non_breaking
  end

  @input_object_type = input_object_type
  @field = field
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality.



631
632
633
# File 'lib/graphql/schema_comparator/changes.rb', line 631

def criticality
  @criticality
end

#fieldObject (readonly)

Returns the value of attribute field.



631
632
633
# File 'lib/graphql/schema_comparator/changes.rb', line 631

def field
  @field
end

#input_object_typeObject (readonly)

Returns the value of attribute input_object_type.



631
632
633
# File 'lib/graphql/schema_comparator/changes.rb', line 631

def input_object_type
  @input_object_type
end

Instance Method Details

#messageObject



644
645
646
# File 'lib/graphql/schema_comparator/changes.rb', line 644

def message
  "Input field `#{field.graphql_name}` was added to input object type `#{input_object_type.graphql_name}`"
end

#pathObject



648
649
650
# File 'lib/graphql/schema_comparator/changes.rb', line 648

def path
  field.path
end