graphiti 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df6cf17d52242b009350cdbfcee3da740db0eb495d31fcebaa4a64f488e0f847
4
- data.tar.gz: d76151e67afde1fe2b5767e017aef86a9b1f2764bfed8bf88465f807c6c1c70d
3
+ metadata.gz: 30c83060dec6dbefde24170e461c2d2a82447ef77f050acf78cfd3a9dd46b1e6
4
+ data.tar.gz: 16bb19c4b54461098992d5a318e812bcf74f1b6a2cb49683a43d61f888599426
5
5
  SHA512:
6
- metadata.gz: b5afa624af4b2c280d1f818eeed4f9f90a87330494ecebb6995861a4541a4da5979a122168a45da42185ae056210bc1cf75f56682dcb06631a369125719b1bd9
7
- data.tar.gz: e81fbd136f7e948be6bd77f87869d9d10b7fd96d6aea4fe8b9b435c6da35fb68620a2f8290ce0095028a79a07625b8a9a6b0e13bc9e50c6af6138c1d8112a667
6
+ metadata.gz: df3aa94529b3e261db005cb09533a3edb838c26187daac12863dcc2d71e2663b43f2784a58bace69c60781e97de42dd2a087b4a87159559cd9ba64d7b61cb055
7
+ data.tar.gz: bce4cb95504b17925469722ec53669c9ac0126ebc1b507b00ea65829f7b9ce3294f9123b6558fa7cd9f1aaaadedca7c1de4720a5014da20a52136c2ab6c7e1a6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  graphiti changelog
2
2
 
3
+ ## [2.2.1](https://github.com/graphiti-api/graphiti/compare/v2.2.0...v2.2.1) (2026-10-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * a create or update override receives decoded foreign keys, not the public ids the client posted ([971d144](https://github.com/graphiti-api/graphiti/commit/971d144a323625b5d1b03f6e4ab551a4dfee12c4))
9
+
3
10
  # [2.2.0](https://github.com/graphiti-api/graphiti/compare/v2.1.3...v2.2.0) (2026-10-13)
4
11
 
5
12
 
@@ -86,8 +86,6 @@ module Graphiti
86
86
  assign_params = assign_params.except(:id).merge(self.class.model_primary_key => primary_key)
87
87
  end
88
88
 
89
- assign_params = decode_foreign_keys(assign_params)
90
-
91
89
  run_callbacks :attributes, action_name, assign_params, meta do |params|
92
90
  model_instance ||= if action_name == :update
93
91
  self.class._find(id: id).data
@@ -29,7 +29,7 @@ class Graphiti::Util::Persistence
29
29
  end
30
30
 
31
31
  def assign
32
- attributes = @adapter.persistence_attributes(self, @attributes)
32
+ attributes = decode_foreign_keys(@adapter.persistence_attributes(self, @attributes))
33
33
  assigned = @resource.assign(attributes, metadata, @meta[:method], model_instance: @assigned_model)
34
34
  @resource.decorate_record(assigned)
35
35
 
@@ -60,7 +60,9 @@ class Graphiti::Util::Persistence
60
60
 
61
61
  payload_attributes = attributes.dup
62
62
  parents = @adapter.process_belongs_to(self, attributes)
63
- apply_derived_attributes(attributes, payload_attributes)
63
+ derived_keys = derived_keys(attributes, payload_attributes)
64
+ attributes = decode_foreign_keys(attributes)
65
+ apply_derived_attributes(attributes.slice(*derived_keys))
64
66
  persisted = persist_object(@meta[:method], attributes)
65
67
  @resource.decorate_record(persisted)
66
68
 
@@ -99,15 +101,23 @@ class Graphiti::Util::Persistence
99
101
  # +attributes+. A model that was already assigned (see ResourceProxy#assign_attributes)
100
102
  # predates those keys, so apply just them - the payload attributes are already on it,
101
103
  # and re-applying them would clobber any changes made since.
102
- def apply_derived_attributes(attributes, payload_attributes)
104
+ def apply_derived_attributes(derived)
103
105
  return unless @assigned_model
104
-
105
- derived = @resource.decode_foreign_keys(attributes).reject { |key, value| payload_attributes[key] == value }
106
106
  return if derived.empty?
107
107
 
108
108
  @resource.assign_attributes(@assigned_model, derived, metadata)
109
109
  end
110
110
 
111
+ def derived_keys(attributes, payload_attributes)
112
+ attributes.keys.reject { |key| payload_attributes.key?(key) && payload_attributes[key] == attributes[key] }
113
+ end
114
+
115
+ def decode_foreign_keys(attributes)
116
+ return attributes if @meta[:method] == :destroy
117
+
118
+ @resource.decode_foreign_keys(attributes)
119
+ end
120
+
111
121
  def add_hook(prc, lifecycle_event)
112
122
  ::Graphiti::Util::TransactionHooksRecorder.add(prc, lifecycle_event)
113
123
  end
@@ -1,3 +1,3 @@
1
1
  module Graphiti
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond