Class: GraphQL::SchemaComparator::Diff::Schema
- Inherits:
-
Object
- Object
- GraphQL::SchemaComparator::Diff::Schema
- Defined in:
- lib/graphql/schema_comparator/diff/schema.rb
Instance Method Summary collapse
- #changes_in_directives ⇒ Object
- #changes_in_schema ⇒ Object
- #changes_in_type(old_type, new_type) ⇒ Object
- #diff ⇒ Object
-
#initialize(old_schema, new_schema) ⇒ Schema
constructor
A new instance of Schema.
Constructor Details
#initialize(old_schema, new_schema) ⇒ Schema
Returns a new instance of Schema.
14 15 16 17 18 19 20 |
# File 'lib/graphql/schema_comparator/diff/schema.rb', line 14 def initialize(old_schema, new_schema) @old_schema = old_schema @new_schema = new_schema @old_types = old_schema.types @new_types = new_schema.types end |
Instance Method Details
#changes_in_directives ⇒ Object
88 89 90 91 |
# File 'lib/graphql/schema_comparator/diff/schema.rb', line 88 def changes_in_directives # TODO [] end |
#changes_in_schema ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/graphql/schema_comparator/diff/schema.rb', line 70 def changes_in_schema changes = [] if old_schema.query != new_schema.query changes << Changes::SchemaQueryTypeChanged.new(old_schema, new_schema) end if old_schema.mutation != new_schema.mutation changes << Changes::SchemaMutationTypeChanged.new(old_schema, new_schema) end if old_schema.subscription != new_schema.subscription changes << Changes::SchemaSubscriptionTypeChanged.new(old_schema, new_schema) end changes end |
#changes_in_type(old_type, new_type) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/graphql/schema_comparator/diff/schema.rb', line 43 def changes_in_type(old_type, new_type) changes = [] if old_type.kind != new_type.kind changes << Changes::TypeKindChanged.new(old_type, new_type) else case old_type when GraphQL::EnumType changes += Diff::Enum.new(old_type, new_type).diff when GraphQL::UnionType changes += Diff::Union.new(old_type, new_type).diff when GraphQL::InputObjectType changes += Diff::InputObject.new(old_type, new_type).diff when GraphQL::ObjectType changes += Diff::ObjectType.new(old_type, new_type).diff when GraphQL::InterfaceType changes += Diff::Interface.new(old_type, new_type).diff end end if old_type.description != new_type.description changes << Changes::TypeDescriptionChanged.new(old_type, new_type) end changes end |
#diff ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/graphql/schema_comparator/diff/schema.rb', line 22 def diff changes = [] # Removed and Added Types changes += removed_types.map { |type| Changes::TypeRemoved.new(type) } changes += added_types.map { |type| Changes::TypeAdded.new(type) } # Type Diff for common types each_common_type do |old_type, new_type| changes += changes_in_type(old_type, new_type) end # Diff Schemas changes += changes_in_schema # Diff Directives changes += changes_in_directives changes end |