class GraphQL::SchemaComparator::Changes::Criticality
Defines the criticality of a {Change} object.
Constants
- BREAKING
Breaking criticality are changes that immediatly impact clients usually causing queries not to be valid anymore.
- DANGEROUS
Dangerous criticality defines changes that are not breaking the schema, but may break runtime logic on clients if they did not code defensively enough to prevent these changes.
- NON_BREAKING
Non-breaking criticality usually defines changes that are always safe to make to a
GraphQL
Schema. They do not require any changes on the client side
Attributes
Public Class Methods
Returns a new Criticality
object with a BREAKING
level @param reason [String] optional reason for this criticality @return [GraphQL::SchemaComparator::Changes::Criticality]
# File lib/graphql/schema_comparator/changes/criticality.rb, line 27 def breaking(reason: "This change is a breaking change") new( level: BREAKING, reason: reason ) end
Returns a new Criticality
object with a DANGEROUS
level @param reason [String] optional reason for this criticality @return [GraphQL::SchemaComparator::Changes::Criticality]
# File lib/graphql/schema_comparator/changes/criticality.rb, line 47 def dangerous(reason: "This change is dangerous") new( level: DANGEROUS, reason: reason ) end
Creates a new Criticality
object
@param level [Symbol] The criticality level @param reason [String] The reason why this criticality is set on the change
# File lib/graphql/schema_comparator/changes/criticality.rb, line 59 def initialize(level: NON_BREAKING, reason: nil) @level = level @reason = reason end
Returns a new Criticality
object with a NON_BREAKING
level @param reason [String] optional reason for this criticality @return [GraphQL::SchemaComparator::Changes::Criticality]
# File lib/graphql/schema_comparator/changes/criticality.rb, line 37 def non_breaking(reason: "This change is safe") new( level: NON_BREAKING, reason: reason ) end
Public Instance Methods
# File lib/graphql/schema_comparator/changes/criticality.rb, line 64 def <=>(other) if level == other.level 0 elsif level < other.level -1 else 1 end end
# File lib/graphql/schema_comparator/changes/criticality.rb, line 74 def breaking? @level == BREAKING end
# File lib/graphql/schema_comparator/changes/criticality.rb, line 82 def dangerous? @level == DANGEROUS end
# File lib/graphql/schema_comparator/changes/criticality.rb, line 78 def non_breaking? @level == NON_BREAKING end