Relationship Data - missing or by design?
See original GitHub issueShould I always see relationship data, regardless of link config or include query?
By this, I mean /items
currently produces:
{
"data": [
{
"type": "items",
"id": "item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe",
"attributes": {
"type": 0,
"title": "New York",
"cover": null,
"slug": null,
"version": 1
},
"relationships": {
"owner": {
"links": {
"self": "/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/relationships/owner",
"related": "/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/owner"
},
"createdBy": {},
"updatedBy": {},
"deletedBy": {}
}
}
}
]
}
If I include owner
(/items?include=owner
):
{
"data": [
{
"type": "items",
"id": "item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe",
"attributes": {
"type": 0,
"title": "New York",
"cover": null,
"slug": null,
"version": 1
},
"relationships": {
"owner": {
"links": {
"self": "/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/relationships/owner",
"related": "/items/item-de4e78d3-b2ec-48dd-8dd7-6088881a2bfe/owner"
},
"data": {
"type": "users",
"id": "user-b607e7dc-3a9d-4360-8495-dd37c4c99de8"
}
},
"createdBy": {},
"updatedBy": {},
"deletedBy": {}
}
}
],
"included": [
{
"type": "users",
"id": "user-b607e7dc-3a9d-4360-8495-dd37c4c99de8",
"attributes": {
"email": "poo@shorthand.com",
"firstName": "Matthew",
"lastName": "Gint2y",
"slug": "slugger",
"version": 1
},
"relationships": {
"createdBy": {},
"updatedBy": {},
"deletedBy": {}
}
}
]
}
Even when I am not asking for includes
(or if links
are turned off), I was expecting the relationships to always have data:
"relationships": {
"owner": {
"data": {
"type": "users",
"id": "user-b607e7dc-3a9d-4360-8495-dd37c4c99de8"
}
},
Is this expected behavior or am I potentially missing something on my model?
[HasOne("owner")]
public virtual User Owner { get; set; }
public string OwnerId { get; set; }
Based on http://jsonapi.org/format/#document-resource-objects and their { article }
snippet, it suggests data should be there… I must be missing something somewhere?
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (10 by maintainers)
Top Results From Across the Web
Meaning of "missing by design" in longitudinal studies
The main idea of planned missing data designs is that you deliberately decide not to gather some data because you assume that you...
Read more >Survey analysis with missing data by design - Cross Validated
Missing by design : Planned missing-data designs in social science. ASK. ... but it's easy, and this gets you an estimate of the...
Read more >Relationship between two tables with missing data
Solved: Have a question about the relationship between two tables. I have a purch order table and a container table.
Read more >Solved: Relationships with missing data
Solved: Hi all. I need to create a relationship connecting table 1 and table 2. If I create a link using only ID...
Read more >Planned Missing-Data Designs in Social Science
In planned missing-data designs some parts of information about respondent are purposely not collected.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hy @jaredcnance.
After setting customerId as optional:
public int? CustomerId { get; set; }
the GET request returns all data relationships. But on the POST Method dotnet quits unexpectedly.
Hy.
I’m using Version 2.1.0 and would like to receive the relationships data object an every GET request. Is there any possibility to get only the { type, id } relationship infos without the included object?
some example: