-
Notifications
You must be signed in to change notification settings - Fork 91
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
Support for including the data
attribute in relationships
#8
Comments
I just quickly skimmed that, so tell me if I've got this wrong, but I'm pretty sure you're just talking about what the spec calls "full linkage"—ie. that included objects can also include data and relationships that link to each other for both to-one and to-many, so that if you "include:" things that are related backwards and forwards, you get all the relationship information. This is something that was pretty complex to support, but I definitely got that working. :) Check out https://github.com/fotinakis/jsonapi-serializers#compound-documents-and-includes, see the Let me know if that doesn't cover what you're talking about. |
Not exactly. Let's take the example JSON form the official website: https://gist.github.com/mrcasals/7353c916f256279ea391 (saved here just in case it changes). If I analyze the post form The issue I linked to asks whether an Taking that, I can have an This is what I want to achieve: "included": [{
"type": "people",
"id": "9",
"attributes": {
"first-name": "Dan",
"last-name": "Gebhardt",
"twitter": "dgeb"
},
"links": {
"self": "http://example.com/people/9"
},
"relationships":{
"posts":{
"data":[{
"type":"posts",
"id":"1"
}, {
"type":"posts",
"id":"2"
}]
}
}
}] This could be done, for example, including always the |
I agree with @mrcasals here. In the app I'm working on, I want to serialize a Like @mrcasals said, it would be nice if the |
It's been a while, but I now understand what you're asking for here. :) Also discussing in #23, where we might be able to do this automatically if you provide a hint of how to lookup the ID. |
Note to self: actually, this is similar but unrelated to the other issues, this specifically is about having deeper |
I did a quick hack to have linkage-level meta working: https://github.com/maukoquiroga/jsonapi-serializers/commit/ec197cc4d7ab841aa70727774b420220a0f52a06. I leave it here if it helps others to better grasp one possible scenario. |
This is finally complete via #70 and launched in v0.11.0 of the gem. See the docs: https://github.com/fotinakis/jsonapi-serializers#control-links-and-data-in-relationships |
Hi!
I opened this issue in the official repo: json-api/json-api#758, open it so that you get the context of this issue. One of the suggested solutions is using the
meta
keyword on a relationship to flag whether it's ato_one
or ato_many
realtionship, but it's weird to me. The other suggestion is to include thedata
keyword for all relationships in theincluded
objects.Is there any way to specify that I want to add the
data
attribute on those relationships?Thanks!
The text was updated successfully, but these errors were encountered: