Class: GraphQL::SchemaComparator::Changes::RootOperationTypeChanged

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(old_schema:, new_schema:, operation_type:) ⇒ RootOperationTypeChanged

Returns a new instance of RootOperationTypeChanged.



238
239
240
241
242
243
# File 'lib/graphql/schema_comparator/changes.rb', line 238

def initialize(old_schema:, new_schema:, operation_type:)
  @old_schema = old_schema
  @new_schema = new_schema
  @operation_type = operation_type
  @criticality = Changes::Criticality.breaking
end

Instance Attribute Details

#criticalityObject (readonly)

Returns the value of attribute criticality.



236
237
238
# File 'lib/graphql/schema_comparator/changes.rb', line 236

def criticality
  @criticality
end

#new_schemaObject (readonly)

Returns the value of attribute new_schema.



236
237
238
# File 'lib/graphql/schema_comparator/changes.rb', line 236

def new_schema
  @new_schema
end

#old_schemaObject (readonly)

Returns the value of attribute old_schema.



236
237
238
# File 'lib/graphql/schema_comparator/changes.rb', line 236

def old_schema
  @old_schema
end

#operation_typeObject (readonly)

Returns the value of attribute operation_type.



236
237
238
# File 'lib/graphql/schema_comparator/changes.rb', line 236

def operation_type
  @operation_type
end

Instance Method Details

#messageObject



245
246
247
# File 'lib/graphql/schema_comparator/changes.rb', line 245

def message
  "Schema #{operation_type} root has changed from `#{operation_type_name(old_schema)}` to `#{operation_type_name(new_schema)}`"
end

#operation_type_name(schema) ⇒ Object



253
254
255
256
257
258
259
260
261
262
# File 'lib/graphql/schema_comparator/changes.rb', line 253

def operation_type_name(schema)
  case operation_type
    when :query
      schema.query.graphql_name
    when :mutation
      schema.mutation.graphql_name
    when :subscription
      schema.subscription.graphql_name
  end
end

#pathObject



249
250
251
# File 'lib/graphql/schema_comparator/changes.rb', line 249

def path
  operation_type_name(old_schema)
end