diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e84a3dd..f01d7c5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ graphiti changelog +## [1.7.6](https://github.com/graphiti-api/graphiti/compare/v1.7.5...v1.7.6) (2024-11-06) + + +### Bug Fixes + +* Gem version check ([#483](https://github.com/graphiti-api/graphiti/issues/483)) ([68e2492](https://github.com/graphiti-api/graphiti/commit/68e2492032692d8bb928a733f8b0f8710be31c49)) + ## [1.7.5](https://github.com/graphiti-api/graphiti/compare/v1.7.4...v1.7.5) (2024-09-16) diff --git a/lib/graphiti/adapters/active_record.rb b/lib/graphiti/adapters/active_record.rb index 366ac71a..c474c183 100644 --- a/lib/graphiti/adapters/active_record.rb +++ b/lib/graphiti/adapters/active_record.rb @@ -304,7 +304,7 @@ def destroy(model_instance) end def close - if ::ActiveRecord.version > "7.2" + if ::ActiveRecord.version > Gem::Version.new("7.2") ::ActiveRecord::Base.connection_handler.clear_active_connections! else ::ActiveRecord::Base.clear_active_connections! diff --git a/lib/graphiti/serializer.rb b/lib/graphiti/serializer.rb index ae581ba3..547b2591 100644 --- a/lib/graphiti/serializer.rb +++ b/lib/graphiti/serializer.rb @@ -13,8 +13,7 @@ class Serializer < JSONAPI::Serializable::Resource class_attribute :attributes_applied_via_resource class_attribute :extra_attributes_applied_via_resource class_attribute :relationship_condition_blocks - class_attribute :field_condition_blocks - self.field_condition_blocks ||= {} + self.attributes_applied_via_resource = [] self.extra_attributes_applied_via_resource = [] # See #requested_relationships diff --git a/lib/graphiti/util/serializer_attributes.rb b/lib/graphiti/util/serializer_attributes.rb index c192d48c..2f05fc5e 100644 --- a/lib/graphiti/util/serializer_attributes.rb +++ b/lib/graphiti/util/serializer_attributes.rb @@ -47,7 +47,7 @@ def previously_applied_via_resource? end def previously_guarded? - @serializer.field_condition_blocks[@name] + @serializer.respond_to?(:field_condition_blocks) && @serializer.field_condition_blocks[@name] end def remove_guard diff --git a/spec/schema_diff_spec.rb b/spec/schema_diff_spec.rb index 64bfd480..ae6d0038 100644 --- a/spec/schema_diff_spec.rb +++ b/spec/schema_diff_spec.rb @@ -490,9 +490,15 @@ def self.name end it "returns error" do - expect(diff).to eq([ - 'SchemaDiff::EmployeeResource: default sort changed from [{:foo=>"asc"}] to [{:foo=>"desc"}].' - ]) + if RUBY_VERSION >= "3.4" + expect(diff).to eq([ + 'SchemaDiff::EmployeeResource: default sort changed from [{foo: "asc"}] to [{foo: "desc"}].' + ]) + else + expect(diff).to eq([ + 'SchemaDiff::EmployeeResource: default sort changed from [{:foo=>"asc"}] to [{:foo=>"desc"}].' + ]) + end end end @@ -1204,9 +1210,15 @@ def self.name end it "returns error" do - expect(diff).to eq([ - 'Endpoint "/schema_diff/employees" had incompatible sideload allowlist. Was [{:positions=>"department"}, "same"], now ["positions", "same"].' - ]) + if RUBY_VERSION >= "3.4" + expect(diff).to eq([ + 'Endpoint "/schema_diff/employees" had incompatible sideload allowlist. Was [{positions: "department"}, "same"], now ["positions", "same"].' + ]) + else + expect(diff).to eq([ + 'Endpoint "/schema_diff/employees" had incompatible sideload allowlist. Was [{:positions=>"department"}, "same"], now ["positions", "same"].' + ]) + end end end end