-
Notifications
You must be signed in to change notification settings - Fork 296
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
included
parameter potentially includes the object itself
#524
Comments
I think this is a tricky issue as it might be that different frameworks have different expectations. Question is what the specification defines in the end to see where it needs to be fixed. Specification of discussion would be on compound documents which sound a bit ambiguous on this issue. This said do you have any other discussion links within the Ember or JSON API community where this issue has been discussed? |
I didn't post this anywhere else. When I re-read the specification I thought it is pretty clear on this:
|
Here the specification states that compound document is the top-level included member. This doesn't include the default resource object, so the statement that If it is understood this way how DJA implements it now would be OK. I think in terms of payload fixing this would actually make sense, I am just not so sure on the clarity of the specification on this point, so it would be good to clarify it. |
The crucial point is that it says in your quote in a compound document. It doesn't say that the included top level member is the compound document itself. IMHO the specification is quite clear about what a compound document is:
i.e. the full response, including the However, I will open an issue on the JSON API side later today. |
I have overread this part, but with this in mind I agree that a resource object should not be added twice including primary data. I guess it never can hurt to double check though with JSON API. Marking this as bug and a Pull Request is very welcome. |
I didn't have the time to create the issue at JSON API. I'll leave it at that and look into fixing the problem. Would you happen to have some pointers for me to where to start looking to fix this? |
The resource itself should be part of the included_cache so it will be skipped in the renderer if it gets included again. |
I'm almost ready to submit the PR. Before I do a couple of questions:
|
I just sent a PR for you to check out what I did. Feel free to reject the PR if it doesn't include everything I should have provided. |
Let's say we have a class
Room
and a classPerson
with a foreign key toRoom
. Now I want to create a new person in the room and reload all the people already in the room because adding the person might have changed them for some reason. Therefor I send aPOST
request containing the new person toThis lead to the newly created person to be included twice, once in the
data
property of the reply and once in theincluded
property. Even though this isn't explicitly forbidden by jsonapi.org, Ember doesn't like this. IMHO an object shouldn't be included twice in a reply - meaning that this should be fixed on the DJA side of things.The text was updated successfully, but these errors were encountered: