Class: GraphQL::SchemaComparator::Changes::RootOperationTypeAdded

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractChange

#breaking?, #dangerous?, #non_breaking?

Constructor Details

#initialize(new_schema:, operation_type:) ⇒ RootOperationTypeAdded

Returns a new instance of RootOperationTypeAdded.



207
208
209
210
211
212
213
# File 'lib/graphql/schema_comparator/changes.rb', line 207

def initialize(new_schema:, operation_type:)
  @new_schema = new_schema
  @operation_type = operation_type
  @criticality = Changes::Criticality.non_breaking(
    reason: "Adding a schema #{operation_type} root is considered non-breaking."
  )
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality.



205
206
207
# File 'lib/graphql/schema_comparator/changes.rb', line 205

def criticality
  @criticality
end

#new_schemaObject (readonly)

Returns the value of attribute new_schema.



205
206
207
# File 'lib/graphql/schema_comparator/changes.rb', line 205

def new_schema
  @new_schema
end

#operation_typeObject (readonly)

Returns the value of attribute operation_type.



205
206
207
# File 'lib/graphql/schema_comparator/changes.rb', line 205

def operation_type
  @operation_type
end

Instance Method Details

#messageObject



215
216
217
# File 'lib/graphql/schema_comparator/changes.rb', line 215

def message
  "Schema #{operation_type} root `#{operation_type_name}` was added"
end

#operation_type_nameObject



223
224
225
226
227
228
229
230
231
232
# File 'lib/graphql/schema_comparator/changes.rb', line 223

def operation_type_name
  case operation_type
    when :query
      new_schema.query.graphql_name
    when :mutation
      new_schema.mutation.graphql_name
    when :subscription
      new_schema.subscription.graphql_name
  end
end

#pathObject



219
220
221
# File 'lib/graphql/schema_comparator/changes.rb', line 219

def path
  operation_type_name
end