question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relationship Data - missing or by design?

See original GitHub issue

Should 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:closed
  • Created 6 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
wurmrobertcommented, Jun 22, 2018

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.

1reaction
wurmrobertcommented, Jun 9, 2018

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:

{
  "data": {
    "type": "photos",
    "attributes": {
      "title": "Ember Hamster",
      "src": "http://example.com/images/productivity.png"
    },
    "relationships": {
      "photographer": {
        "data": { "type": "people", "id": "9" }
      }
    }
  }
}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found