-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Related item without attributes not in includes #109
Comments
There was a feature where we didn't include objects if there was no additional information beyond what we could put in the relationship. The reason for this was to allow creating 'stub' objects that just contain an A possible workaround is to explicitly define var root = DocumentRoot.Create(new
{
Id = "1234",
Type = "contact-info",
Emails = new List<ResourceIdentifier<EmailAddress>>()
{
new ResourceIdentifier<EmailAddress>
{
Value = new EmailAddress
{
Id = 4
}
},
new ResourceIdentifier<EmailAddress>
{
Value = new EmailAddress
{
Id = 5,
Email = "[email protected]"
}
}
}
}); |
Thank you for your answer. Unfortunately, I won't be able to use your suggestion as I use the Relationship class to define my relationships in my dto. I went that way because I needed to manage the links for the relationship objects. However, looking at the code and documentation (https://github.com/codecutout/JsonApiSerializer#links), it would seem that I could've created a "Links" property in my dto to hold the "self" and "related" links. (please correct me if I'm wrong) I recommended to my developer to add a "dummy" property as a workaround for now while I look into this. It will force the object in the includes and won't affect the front-end as the property is not defined on that side. It's less than ideal and ugly but at least it puts a band-aid on the issue for now. |
I know it's not directly in link with the original question in this thread but I'm not sure where else to ask. I've been exploring/thinking about this a bit more and how would you handle the case where you want to specify links for the relationship itself when the relationship is an array? The cases I want to cover are:
How do I get the serializer to distinguis between each item's "self" link and the whole array relationship "self" and "related" links in cases 1 and 2? I used the "compound document" section in the JsonApi standard as reference: https://jsonapi.org/format/#document-compound-documents |
I have encountered a problem where the "includes" section of the answer doesn't include one of the related item because it has no attrbutes to show. There's only the Id and Type and a (not included)child object that are populated.
The email with Id 4 should look like this within the include
At first I was thinking that repeating the information for the email Id 4 would be redundant because there's no attributes. However, I think that it should be included even if it's only the id and type to at least tell the other party (front end) that the entry exists and is empty. The current answer let the other party think that the entry was not provided and they will try to get the entry through a separate query.
The text was updated successfully, but these errors were encountered: