-
Notifications
You must be signed in to change notification settings - Fork 14
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
relationships routing and fetching - what is the status and plans for that? #36
Comments
Hi Cezary, thank you for your issue. You're quite right, NJsonApiCore doesn't support the fetching/updating of relationships and that is a pain! It's going to become critical at our company soon so I think it's wise we start with a discussion. I think it's more than a few hours work! The As per the json:api spec,
Response is:
As you can see it is a relationship object. ResponsibilitiesTo help us find a solution, let's specify the responsibilities.
That should be enough for now, we can add to that later if need be. Let's look at the different operations. GET RelationshipOn the Response, NJsonApiCore needs to create the relationship object (it's not the responsibility of the programmer). To do that it needs the resource. The Programmer needs to get that from storage and to do that the Programmer needs a method on the MVC controller. I don't like that the programmer creating a GET method for each relationship. The Programmer shouldn't care. So instead, NJsonApiCore should hijack the Request and call the controller method that is registered for GET. It takes the resource that the GET method returned and instead of serializing the whole resource, it serializes just the relationship that's been asked for and sends that back. The Programmer isn't doing any more work in this case as they already have a GET method that returns the requested resource. PATCH/POST/DELETEThis is more open to conversation. In this case, the Programmer needs to do some work. A relationship between two objects in storage needs to change. There are two options: new controller methods for each relationship and change or update the The change to As an aside, I'm not in love with the How does that sound so far? |
Thanks for extensive reply. Let's concentrate on the GET first. I would like to consider this scenarios:
For the above to work, programmer needs to be aware that only a related resource was requested. |
As per jsonapi spec:
http://jsonapi.org/format/#fetching-relationships
I tried to fetch related resources using /articles/id/relationships/author in the given example and it seems it couldn't get it work.
I tried to look at the implementation, add missing routing, etc. It looks like the current NJSONAPICORE doesn't account for that part of the spec.
If I am mistaken, would someone be kind and help me out with example?
If I am right, could we start a discussion on how to best implement it? I would willingly contribute towards the implementation.
The questions would be:
JSONAPICORE for the moment is by far the best implementation of the JSONAPI I found. It would be great to add that missing piece, and I will gladly contribute. If we can agree on approach related to the above questions, I guess I could plan quite a few hours pretty soon.
Thanks,
Cezary
The text was updated successfully, but these errors were encountered: