Class: GraphQL::SchemaComparator::Changes::Criticality

Inherits:
Object
  • Object
show all
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

:NON_BREAKING
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.

:DANGEROUS
BREAKING =

Breaking criticality are changes that immediatly impact clients usually causing queries not to be valid anymore.

:BREAKING

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level: NON_BREAKING, reason: nil) ⇒ Criticality

Creates a new Criticality object

Parameters:

  • level (Symbol)

    The criticality level

  • reason (String)

    The reason why this criticality is set on the change


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

#levelObject (readonly)

Returns the value of attribute level


21
22
23
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 21

def level
  @level
end

#reasonObject (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

Parameters:

  • reason (String)

    optional reason for this criticality

Returns:


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

Parameters:

  • reason (String)

    optional reason for this criticality

Returns:


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

Parameters:

  • reason (String)

    optional reason for this criticality

Returns:


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

#breaking?Boolean

Returns:

  • (Boolean)

64
65
66
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 64

def breaking?
  @level == BREAKING
end

#dangerous?Boolean

Returns:

  • (Boolean)

72
73
74
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 72

def dangerous?
  @level == DANGEROUS
end

#non_breaking?Boolean

Returns:

  • (Boolean)

68
69
70
# File 'lib/graphql/schema_comparator/changes/criticality.rb', line 68

def non_breaking?
  @level == NON_BREAKING
end