Closed BahaaAlhagar closed 2 years ago
I was trying to use DocumentHydrator to hydrate incoming request
I found out an issue on the Hydrator relationship is not included it gets ignored
consider this example
`{ "data": { "id": "", "type": "used_car", "attributes": { "year": 1972, "colour_code": "#111111", "gearbox": "manual", "transmission": "gasoline", "moved_kilometers": "1000", "selling_price": "1000", "price_negotiable": false, "seller_phone_number": "01288530263", "whatsapp_enabled": false, "address": "1000 street at gmail", "car_information": "some more car infromation", "status": "draft" }, "relationships": { "brand": { "data": { "id": "9", "type": "brand" } }, "carBodyShape": { "data": { "id": "2", "type": "car_body_shape" } }, "carModel": { "data": { "id": "3", "type": "car_model" } }, "carGrade": { "data": { "id": "4", "type": "car_model" } }, "country": { "data": { "id": "4", "type": "country" } }, "city": { "data": { "id": "4", "type": "city" } }, "area": { "data": { "id": "4", "type": "area" } }, "more_licenses": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28wec4e135", "type": "used_car_license" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb38ewc4e136", "type": "used_car_license" } ] }, "licenses": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e135", "type": "used_car_license" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e136", "type": "used_car_license" } ] }, "internalImages": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e135", "type": "used_car_image" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e136", "type": "used_car_image" } ] }, "externalImages": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e137", "type": "used_car_image" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e138", "type": "used_car_image" } ] } } }, "included": [ { "id": "9", "type": "brand", "attributes": { "title": "repellat" }
}, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e136", "type": "used_car_license", "attributes": { "file": 1, "image_type": "front" } }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e135", "type": "used_car_license", "attributes": { "file": 1, "image_type": "back" } }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e136", "type": "used_car_image", "attributes": { "file": 1, "image_type": "internal" } }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e135", "type": "used_car_image", "attributes": { "file": 1, "image_type": "internal" } }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e137", "type": "used_car_image", "attributes": { "file": 1, "image_type": "external" } }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e138", "type": "used_car_image", "attributes": { "file": 1, "image_type": "external" } } ]
}`
On the last case all relationships that does not have included data gets removed from serialized to json object
This updates add an object for each not included relationship while hydrating data
I was trying to use DocumentHydrator to hydrate incoming request
I found out an issue on the Hydrator relationship is not included it gets ignored
consider this example
`{ "data": { "id": "", "type": "used_car", "attributes": { "year": 1972, "colour_code": "#111111", "gearbox": "manual", "transmission": "gasoline", "moved_kilometers": "1000", "selling_price": "1000", "price_negotiable": false, "seller_phone_number": "01288530263", "whatsapp_enabled": false, "address": "1000 street at gmail", "car_information": "some more car infromation", "status": "draft" }, "relationships": { "brand": { "data": { "id": "9", "type": "brand" } }, "carBodyShape": { "data": { "id": "2", "type": "car_body_shape" } }, "carModel": { "data": { "id": "3", "type": "car_model" } }, "carGrade": { "data": { "id": "4", "type": "car_model" } }, "country": { "data": { "id": "4", "type": "country" } }, "city": { "data": { "id": "4", "type": "city" } }, "area": { "data": { "id": "4", "type": "area" } }, "more_licenses": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28wec4e135", "type": "used_car_license" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb38ewc4e136", "type": "used_car_license" } ] }, "licenses": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e135", "type": "used_car_license" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e136", "type": "used_car_license" } ] }, "internalImages": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e135", "type": "used_car_image" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e136", "type": "used_car_image" } ] }, "externalImages": { "data": [ { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e137", "type": "used_car_image" }, { "id": "bb4c1dba-3d9d-4df1-85d0-7cb28ec4e138", "type": "used_car_image" } ] } } }, "included": [ { "id": "9", "type": "brand", "attributes": { "title": "repellat" }
}`
On the last case all relationships that does not have included data gets removed from serialized to json object
This updates add an object for each not included relationship while hydrating data