We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 48b45f7 commit b35145cCopy full SHA for b35145c
1 file changed
lib/jsonapi_parameters/default_handlers/base_handler.rb
@@ -25,12 +25,16 @@ def find_included_object(related_id:, related_type:)
25
end
26
27
def build_included_object(included_object, related_id)
28
- { **(included_object[:attributes] || {}) }.tap do |body|
+ included_object_base(included_object).tap do |body|
29
body[:id] = related_id unless client_generated_id?(related_id)
30
body[:relationships] = included_object[:relationships] if included_object.key?(:relationships) # Pass nested relationships
31
32
33
34
+ def included_object_base(included_object)
35
+ { **(included_object[:attributes] || {}) }
36
+ end
37
+
38
def client_generated_id?(related_id)
39
related_id.to_s.starts_with?(JsonApi::Parameters.client_id_prefix)
40
0 commit comments