Class: GraphQL::SchemaComparator::Changes::Criticality
- Inherits:
-
Object
- Object
- GraphQL::SchemaComparator::Changes::Criticality
- Defined in:
- lib/graphql/schema_comparator/changes/criticality.rb
Overview
Defines the criticality of a Change object.
Constant Summary collapse
- 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
1
- 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.
2
- BREAKING =
Breaking criticality are changes that immediately impact clients usually causing queries not to be valid anymore.
3
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Class Method Summary collapse
-
.breaking(reason: "This change is a breaking change") ⇒ GraphQL::SchemaComparator::Changes::Criticality
Returns a new Criticality object with a BREAKING level.
-
.dangerous(reason: "This change is dangerous") ⇒ GraphQL::SchemaComparator::Changes::Criticality
Returns a new Criticality object with a DANGEROUS level.
-
.non_breaking(reason: "This change is safe") ⇒ GraphQL::SchemaComparator::Changes::Criticality
Returns a new Criticality object with a NON_BREAKING level.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #breaking? ⇒ Boolean
- #dangerous? ⇒ Boolean
-
#initialize(level: NON_BREAKING, reason: nil) ⇒ Criticality
constructor
Creates a new Criticality object.
- #non_breaking? ⇒ Boolean
Constructor Details
#initialize(level: NON_BREAKING, reason: nil) ⇒ Criticality
Creates a new Criticality object
59 60 61 62 |
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 59 def initialize(level: NON_BREAKING, reason: nil) @level = level @reason = reason end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
21 22 23 |
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 21 def level @level end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
21 22 23 |
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 21 def reason @reason end |
Class Method Details
.breaking(reason: "This change is a breaking change") ⇒ GraphQL::SchemaComparator::Changes::Criticality
Returns a new Criticality object with a BREAKING level
27 28 29 30 31 32 |
# 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 |
.dangerous(reason: "This change is dangerous") ⇒ GraphQL::SchemaComparator::Changes::Criticality
Returns a new Criticality object with a DANGEROUS level
47 48 49 50 51 52 |
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 47 def dangerous(reason: "This change is dangerous") new( level: DANGEROUS, reason: reason ) end |
.non_breaking(reason: "This change is safe") ⇒ GraphQL::SchemaComparator::Changes::Criticality
Returns a new Criticality object with a NON_BREAKING level
37 38 39 40 41 42 |
# 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 |
Instance Method Details
#<=>(other) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# 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 |
#breaking? ⇒ Boolean
74 75 76 |
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 74 def breaking? @level == BREAKING end |
#dangerous? ⇒ Boolean
82 83 84 |
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 82 def dangerous? @level == DANGEROUS end |
#non_breaking? ⇒ Boolean
78 79 80 |
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 78 def non_breaking? @level == NON_BREAKING end |