Closed danielspaniel closed 9 years ago
I am seeing that the answer is no .. since the jsonapi structure is not so loosey goosey
I don't think this has anything to do with "loosey goosey" -- The following is perfectly valid JSONapi:
{
"data": {
"id": "1",
"type": "tickets",
"links": {
"self": "http://localhost:3000/v1/tickets/1"
},
"attributes": {
"title": "Lomo 8-bit vinegar carry listicle pork belly vinyl.",
"description": "I'll copy the solid state COM pixel, that should card the THX alarm!",
"queue": "billing-questions",
"severity": "critical",
"status": "open",
"autotask-id": "T20160113.0001",
"created-at": "2016-01-28T16:56:38Z",
"updated-at": "2016-01-28T16:56:38Z"
},
"relationships": {
"creator": {
"links": {
"self": "http://localhost:3000/v1/tickets/1/relationships/creator",
"related": "http://localhost:3000/v1/tickets/1/creator"
},
"data": {
"type": "users",
"id": "1"
}
},
"notes": {
"links": {
"self": "http://localhost:3000/v1/tickets/1/relationships/notes",
"related": "http://localhost:3000/v1/tickets/1/notes"
}
}
}
},
"included": [
{
"id": "1",
"type": "users",
"links": {
"self": "http://localhost:3000/v1/users/1"
},
"attributes": {
"first-name": "Bertram",
"last-name": "Haley",
"email": "mylene@cremin.org",
"phone": "(746) 565-9521 x17021"
},
"relationships": {
"account": {
"links": {
"self": "http://localhost:3000/v1/users/1/relationships/account",
"related": "http://localhost:3000/v1/users/1/account"
},
"data": {
"type": "accounts",
"id": "1"
}
}
}
},
{
"id": "1",
"type": "accounts",
"links": {
"self": "http://localhost:3000/v1/accounts/1"
},
"attributes": {
"name": "Account 1",
}
}
]
}
I think your saying you can sideload what ever you want. For some reason it did not work for me, but I will revisit when I get back to trying JSON API serializer again.
Oh -- I'm just saying the JSONapi SPEC allows for this to happen, but the jsonapi-resources
rails gem does not have that functionality... yet
:+1: for this as a feature request, by the way. It would be very valuable to us. As far as the way to do it.. that's a different discussion.
Hmm .. yeah .. good points.
I am trying to 'include' ( side load ) records that are not directly ( though indirectly ) related to the primary resource object being serialized. Is there a way to do that? I tried to using the includes hash, but if that have does not find the association in the resource, it ignores it.
I want to include the buildings but they are not part of the project model directly, so they don't show up. I could do 'sites.buildings' but I want to avoid too much nesting, since the buildings have the has_one :site already.
Does that make sense?
I am arriving at jsonapi from the active model serializer world where you could side load anything you wanted with a payload.