graphiti 2.2.0 → 2.2.2

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: 185e66f29378e7e50a478f273bd0c3d2b7cf8116aa3d61668d05d34761ab8d27
4
+ data.tar.gz: 1a7286d5912d8133adb83a2c8bb330cd6876d088a88aab8abc01cee08dfbb251
5
5
  SHA512:
6
- metadata.gz: b5afa624af4b2c280d1f818eeed4f9f90a87330494ecebb6995861a4541a4da5979a122168a45da42185ae056210bc1cf75f56682dcb06631a369125719b1bd9
7
- data.tar.gz: e81fbd136f7e948be6bd77f87869d9d10b7fd96d6aea4fe8b9b435c6da35fb68620a2f8290ce0095028a79a07625b8a9a6b0e13bc9e50c6af6138c1d8112a667
6
+ metadata.gz: 43fc294150c26b1b09ca78290dc864171538f5d988b736d5cbd5db4c77b9979d0a3077ef738452a783b4d9a7668331e7f32a67a1fe657c6a858bc0a77e7c3ae4
7
+ data.tar.gz: 0a7b8ca5bc7ffba5365a1b74c2bc195b6ec56349344eb0ca44445580b0ef9db30654fc030ab135684024d872488d6652bd214d6a67619182f76fb5d4b5038732
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  graphiti changelog
2
2
 
3
+ ## [2.2.2](https://github.com/graphiti-api/graphiti/compare/v2.2.1...v2.2.2) (2026-10-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * nested includes dropped by sideload_allowlist ([#549](https://github.com/graphiti-api/graphiti/issues/549)) ([96b05df](https://github.com/graphiti-api/graphiti/commit/96b05df9b4514d946c639ed157b08e99e37b3ac0))
9
+ * render fresh included records after an update ([#552](https://github.com/graphiti-api/graphiti/issues/552)) ([aba46ac](https://github.com/graphiti-api/graphiti/commit/aba46acf22414fbc3922e579b44ebdcde6f4c9b4))
10
+
11
+ ## [2.2.1](https://github.com/graphiti-api/graphiti/compare/v2.2.0...v2.2.1) (2026-10-17)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * 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))
17
+
3
18
  # [2.2.0](https://github.com/graphiti-api/graphiti/compare/v2.1.3...v2.2.0) (2026-10-13)
4
19
 
5
20
 
@@ -289,7 +289,7 @@ module Graphiti
289
289
  allowlist = allowlist[@resource.current_action] if allowlist
290
290
  end
291
291
 
292
- scrubbed = allowlist ? Util::IncludeParams.scrub(requested, allowlist) : requested
292
+ scrubbed = (top_level? && allowlist) ? Util::IncludeParams.scrub(requested, allowlist) : requested
293
293
 
294
294
  scrubbed.filter do |key, value|
295
295
  sideload = @resource.class.sideload(key)
@@ -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
@@ -211,6 +211,7 @@ module Graphiti
211
211
  # adapters will cause N+1 validation calls, so lets explicitly
212
212
  # switch to a lookup context.
213
213
  Graphiti.with_context(Graphiti.context[:object], :show) do
214
+ @query.entity_map.clear
214
215
  @scope.resolve_sideloads([@data])
215
216
  end
216
217
  end
@@ -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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond