-
-
Notifications
You must be signed in to change notification settings - Fork 158
Deeply Nested Relationship Inclusion #39
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
Comments
Closing. Will consider re-opening if there is demand. |
This seems like it would be worthwhile to include? A joining table like Maybe with #218 this could be included too? 🙏 |
To flesh this out more, given the following 3 entities: class User {
string Id { get; set; }
...
}
class Item {
public string Id { get; set; }
[NotMapped]
public string StringId { get => this.Id; set => Id = value; }
[ForeignKey("Owner")]
[Column("Owner")]
public string OwnerId { get; set; }
[HasOne("owner", Link.None)]
public User Owner { get; set; }
[NotMapped]
public ICollection<ItemCollaborator> Collaborators { get; set; }
[HasMany("collaborators", Link.None)]
public ICollection<User> Users { get; set; }
}
class ItemCollaborator {
string String Id { get; set; }
[HasOne("item", Link.None)]
Item Item { get; set; }
[ForeignKey("Item")]
[Column("Item")]
string ItemId { get; set; }
[HasOne("user", Link.None)]
User User { get; set; }
[ForeignKey("User")]
[Column("User")]
string UserId { get; set; }
} I would like the result (when {
"relationships": {
"collaborators": {
"data": [
{
"type": "users",
"id": "user-b607e7dc-3a9d-4360-8495-dd37c4c99de8"
}
]
}
} This allows the abstraction of a joining table to remain "database only" when dealing with simple one-to-many relationships where the joining entity includes nothing more than the related entity Ids. Initial solutions to this requirement (via gitter discussions with @jaredcnance) landed on creating a modified version of the default This approach should fall in line with the intention to use reflection when building the ContextGraph so the PropertyInfo is readily available wherever it is needed. |
To add end-user context to the demand... from an end-user perspective this feature is highly desired as nested inclusions are about the only way to retrieve "very common" rich information without making multiple requests to the API. I'm using Ember Data myself which, without this feature, requires hacking around the limitation. |
I'd say this is an essential feature of jsonapi and is one of the biggest things that allows jsonapi to "compete" with features of graphql / custom-solutions. nested includes is a must have for any generic jsonapi implementation (unless you're netflix, apparently) |
Is there enough demand? imo, this is a pretty easy feature to maintain, because as you traverse the object graph, you just check if the object you are about to serialize has already been serialized in the included array. :-\ |
There is definitely enough demand and motivation to begin work on this feature. Unless someone else gets to it first, I will likely begin working on it after some in-flight work is completed (#326, #340, #344). If someone else wants to begin work on this, feel free to ping me on the Gitter channel and I'll be available to answer any questions. |
…n-api-dotnet#39-implementation Feature/json-api-dotnet#39 - Acceptance Tests
…n-api-dotnet#39-implementation-deserializer-unit-test Feature/json-api-dotnet#39 deserializer unit test
…n-api-dotnet#39-implementation-serializer-unit-test Feature/json-api-dotnet#39 serializer unit test
…-api-dotnet#39 [WIP] Feat/json-api-dotnet#39: Deeply Nested Inclusions
Will also need to include support for Sparse Fieldsets of included relationships
The text was updated successfully, but these errors were encountered: