{"action":"created","issue":{"url":"https://api.github.com/repos/tuyakhov/yii2-json-api/issues/47","repository_url":"https://api.github.com/repos/tuyakhov/yii2-json-api","labels_url":"https://api.github.com/repos/tuyakhov/yii2-json-api/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/tuyakhov/yii2-json-api/issues/47/comments","events_url":"https://api.github.com/repos/tuyakhov/yii2-json-api/issues/47/events","html_url":"https://github.com/tuyakhov/yii2-json-api/issues/47","id":303916740,"number":47,"title":"Allow addition of relationship information without full include data","user":{"login":"acorncom","id":802505,"avatar_url":"https://avatars1.githubusercontent.com/u/802505?v=4","gravatar_id":"","url":"https://api.github.com/users/acorncom","html_url":"https://github.com/acorncom","followers_url":"https://api.github.com/users/acorncom/followers","following_url":"https://api.github.com/users/acorncom/following{/other_user}","gists_url":"https://api.github.com/users/acorncom/gists{/gist_id}","starred_url":"https://api.github.com/users/acorncom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acorncom/subscriptions","organizations_url":"https://api.github.com/users/acorncom/orgs","repos_url":"https://api.github.com/users/acorncom/repos","events_url":"https://api.github.com/users/acorncom/events{/privacy}","received_events_url":"https://api.github.com/users/acorncom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-09T17:21:43Z","updated_at":"2018-03-10T16:28:11Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"This is similar to https://github.com/tuyakhov/yii2-json-api/issues/40 but I believe is a bit different.\r\n\r\nI have two models (`MaintenanceRecommendation` and `Car`). If I do this request (`/api/maintenance-recommendations/fix-brakes?include=car`), I will properly send back both the particular recommendation and the related car model.\r\n\r\nBut in my particular use case, I *know* the client will have the `car` model loaded on the client side by the time this request is made, so there is no reason to request that the full `car` relationship be included. The `car` model is also quite heavy and takes additional processing that I would like to skip.\r\n\r\nWhat I'd like to do is send back hint data from the backend so that the client can properly wire the recommendation data to the appropriate car without sending the full payload for the car.\r\n\r\nIdeally, I would call `GET /api/maintenance-recommendations/fix-brakes` and see the following (where the `car` relationship data is populated, but there is no `included` payload added as well):\r\n\r\n```json\r\n{\r\n    \"data\": {\r\n        \"id\": \"FancyCar-fix-brakes\",\r\n        \"type\": \"maintenance-recommendations\",\r\n        \"attributes\": {\r\n            ...\r\n        },\r\n        \"relationships\": {\r\n            \"car\": {\r\n                \"data\": {\r\n                    \"id\": \"FancyCar\",\r\n                    \"type\": \"cars\"\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nAny thoughts on that? From what I've seen in Twitter conversations with the spec author, this type of response would be valid per the spec ... It's in essence server-side hinting that the backend is *allowed* to add without it being required ..."},"comment":{"url":"https://api.github.com/repos/tuyakhov/yii2-json-api/issues/comments/372042620","html_url":"https://github.com/tuyakhov/yii2-json-api/issues/47#issuecomment-372042620","issue_url":"https://api.github.com/repos/tuyakhov/yii2-json-api/issues/47","id":372042620,"user":{"login":"tuyakhov","id":7713205,"avatar_url":"https://avatars0.githubusercontent.com/u/7713205?v=4","gravatar_id":"","url":"https://api.github.com/users/tuyakhov","html_url":"https://github.com/tuyakhov","followers_url":"https://api.github.com/users/tuyakhov/followers","following_url":"https://api.github.com/users/tuyakhov/following{/other_user}","gists_url":"https://api.github.com/users/tuyakhov/gists{/gist_id}","starred_url":"https://api.github.com/users/tuyakhov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuyakhov/subscriptions","organizations_url":"https://api.github.com/users/tuyakhov/orgs","repos_url":"https://api.github.com/users/tuyakhov/repos","events_url":"https://api.github.com/users/tuyakhov/events{/privacy}","received_events_url":"https://api.github.com/users/tuyakhov/received_events","type":"User","site_admin":false},"created_at":"2018-03-10T16:28:11Z","updated_at":"2018-03-10T16:28:11Z","author_association":"OWNER","body":"It seems like a good use case for populating relationship data. I think it's not possible to get the id of a related model without actually looking into the database and loading it. It's easy to do for 'belongs to' relationships when there is an attribute like `car_id`. But what about one-to-many or many-to-many relationships? Not sure if there is a simple way to retrieve that. Also, we have to keep in mind the support of different types of databases.\r\nMaybe it will be a good solution to abstract serializing of relationships object so that it will be easier to extend or overwrite it.\r\nWhat do you think? "}}
{"actor":{"display_login":"tuyakhov"}}