@@ -5,22 +5,20 @@ module Associations
55 def process_belongs_to ( persistence , attributes )
66 parents = [ ] . tap do |processed |
77 persistence . iterate ( only : [ :polymorphic_belongs_to , :belongs_to ] ) do |x |
8- begin
9- id = x . dig ( :attributes , :id )
10- x [ :object ] = x [ :resource ]
11- . persist_with_relationships ( x [ :meta ] , x [ :attributes ] , x [ :relationships ] )
8+ id = x . dig ( :attributes , :id )
9+ x [ :object ] = x [ :resource ]
10+ . persist_with_relationships ( x [ :meta ] , x [ :attributes ] , x [ :relationships ] )
11+ processed << x
12+ rescue Graphiti ::Errors ::RecordNotFound
13+ if Graphiti . config . raise_on_missing_sidepost
14+ path = "relationships/#{ x . dig ( :meta , :jsonapi_type ) } "
15+ raise Graphiti ::Errors ::RecordNotFound . new ( x [ :sideload ] . name , id , path )
16+ else
17+ pointer = "data/relationships/#{ x . dig ( :meta , :jsonapi_type ) } "
18+ object = Graphiti ::Errors ::NullRelation . new ( id . to_s , pointer )
19+ object . errors . add ( :base , :not_found , message : "could not be found" )
20+ x [ :object ] = object
1221 processed << x
13- rescue Graphiti ::Errors ::RecordNotFound
14- if Graphiti . config . raise_on_missing_sidepost
15- path = "relationships/#{ x . dig ( :meta , :jsonapi_type ) } "
16- raise Graphiti ::Errors ::RecordNotFound . new ( x [ :sideload ] . name , id , path )
17- else
18- pointer = "data/relationships/#{ x . dig ( :meta , :jsonapi_type ) } "
19- object = Graphiti ::Errors ::NullRelation . new ( id . to_s , pointer )
20- object . errors . add ( :base , :not_found , message : "could not be found" )
21- x [ :object ] = object
22- processed << x
23- end
2422 end
2523 end
2624 end
0 commit comments