{"action":"created","issue":{"url":"https://api.github.com/repos/json-api-dotnet/JsonApiDotNetCore/issues/218","repository_url":"https://api.github.com/repos/json-api-dotnet/JsonApiDotNetCore","labels_url":"https://api.github.com/repos/json-api-dotnet/JsonApiDotNetCore/issues/218/labels{/name}","comments_url":"https://api.github.com/repos/json-api-dotnet/JsonApiDotNetCore/issues/218/comments","events_url":"https://api.github.com/repos/json-api-dotnet/JsonApiDotNetCore/issues/218/events","html_url":"https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/218","id":284040369,"number":218,"title":"Relationship Data - missing or by design?","user":{"login":"mattgi","id":1043906,"avatar_url":"https://avatars3.githubusercontent.com/u/1043906?v=4","gravatar_id":"","url":"https://api.github.com/users/mattgi","html_url":"https://github.com/mattgi","followers_url":"https://api.github.com/users/mattgi/followers","following_url":"https://api.github.com/users/mattgi/following{/other_user}","gists_url":"https://api.github.com/users/mattgi/gists{/gist_id}","starred_url":"https://api.github.com/users/mattgi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattgi/subscriptions","organizations_url":"https://api.github.com/users/mattgi/orgs","repos_url":"https://api.github.com/users/mattgi/repos","events_url":"https://api.github.com/users/mattgi/events{/privacy}","received_events_url":"https://api.github.com/users/mattgi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-22T00:16:04Z","updated_at":"2017-12-22T01:19:21Z","closed_at":null,"author_association":"NONE","body":"Should I always see relationship data, regardless of link config or include query?\r\n\r\nBy this, I mean `/items` currently produces:\r\n\r\n```\r\n{\r\n    \"data\": [\r\n        {\r\n            \"type\": \"items\",\r\n            \"id\": \"item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe\",\r\n            \"attributes\": {\r\n                \"type\": 0,\r\n                \"title\": \"New York\",\r\n                \"cover\": null,\r\n                \"slug\": null,\r\n                \"version\": 1\r\n            },\r\n            \"relationships\": {\r\n                \"owner\": {\r\n                    \"links\": {\r\n                        \"self\": \"/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/relationships/owner\",\r\n                        \"related\": \"/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/owner\"\r\n                    },\r\n                \"createdBy\": {},\r\n                \"updatedBy\": {},\r\n                \"deletedBy\": {}\r\n                }\r\n            }\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nIf I include `owner` (`/items?include=owner`):\r\n```\r\n{\r\n    \"data\": [\r\n        {\r\n            \"type\": \"items\",\r\n            \"id\": \"item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe\",\r\n            \"attributes\": {\r\n                \"type\": 0,\r\n                \"title\": \"New York\",\r\n                \"cover\": null,\r\n                \"slug\": null,\r\n                \"version\": 1\r\n            },\r\n            \"relationships\": {\r\n                \"owner\": {\r\n                    \"links\": {\r\n                        \"self\": \"/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/relationships/owner\",\r\n                        \"related\": \"/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/owner\"\r\n                    },\r\n                    \"data\": {\r\n                        \"type\": \"users\",\r\n                        \"id\": \"user-b607e7dc-3a9d-4360-8495-dd37c4c99de8\"\r\n                    }\r\n                },\r\n                \"createdBy\": {},\r\n                \"updatedBy\": {},\r\n                \"deletedBy\": {}\r\n            }\r\n        }\r\n    ],\r\n    \"included\": [\r\n        {\r\n            \"type\": \"users\",\r\n            \"id\": \"user-b607e7dc-3a9d-4360-8495-dd37c4c99de8\",\r\n            \"attributes\": {\r\n                \"email\": \"poo@shorthand.com\",\r\n                \"firstName\": \"Matthew\",\r\n                \"lastName\": \"Gint2y\",\r\n                \"slug\": \"slugger\",\r\n                \"version\": 1\r\n            },\r\n            \"relationships\": {\r\n                \"createdBy\": {},\r\n                \"updatedBy\": {},\r\n                \"deletedBy\": {}\r\n            }\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\n\r\nEven when I am not asking for `includes` (or if `links` are turned off), I was expecting the relationships to always have data:\r\n\r\n```\r\n\"relationships\": {\r\n                \"owner\": {\r\n                    \"data\": {\r\n                        \"type\": \"users\",\r\n                        \"id\": \"user-b607e7dc-3a9d-4360-8495-dd37c4c99de8\"\r\n                    }\r\n                },\r\n```\r\n\r\nIs this expected behavior or am I potentially missing something on my model?\r\n\r\n```\r\n      [HasOne(\"owner\")]\r\n      public virtual User Owner { get; set; }\r\n\r\n      public string OwnerId { get; set; }\r\n```\r\n\r\n\r\nBased on http://jsonapi.org/format/#document-resource-objects and their `{ article }` snippet, it suggests data should be there.. I must be missing something somewhere?"},"comment":{"url":"https://api.github.com/repos/json-api-dotnet/JsonApiDotNetCore/issues/comments/353498384","html_url":"https://github.com/json-api-dotnet/JsonApiDotNetCore/issues/218#issuecomment-353498384","issue_url":"https://api.github.com/repos/json-api-dotnet/JsonApiDotNetCore/issues/218","id":353498384,"user":{"login":"jaredcnance","id":13851721,"avatar_url":"https://avatars2.githubusercontent.com/u/13851721?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredcnance","html_url":"https://github.com/jaredcnance","followers_url":"https://api.github.com/users/jaredcnance/followers","following_url":"https://api.github.com/users/jaredcnance/following{/other_user}","gists_url":"https://api.github.com/users/jaredcnance/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredcnance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredcnance/subscriptions","organizations_url":"https://api.github.com/users/jaredcnance/orgs","repos_url":"https://api.github.com/users/jaredcnance/repos","events_url":"https://api.github.com/users/jaredcnance/events{/privacy}","received_events_url":"https://api.github.com/users/jaredcnance/received_events","type":"User","site_admin":false},"created_at":"2017-12-22T01:19:21Z","updated_at":"2017-12-22T01:19:21Z","author_association":"OWNER","body":"I think this is an oversight. In the case of a dependent HasOne relationship we can include this easily and I think maybe we should. However, on the independent side of a HasOne (in the case of a 1:(0-1) relationship) we will not include this because it would necessitate a SQL JOIN and would be unexpected behavior."}}
{"actor":{"display_login":"jaredcnance"}}