-
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
Include intermediate resources on compound documents #50
Conversation
Looks good, except for the big blocks of unformatted hashes. :) See the current style and way that tests are structured in the file, it should be pretty easy to update near comment |
No worries @fotinakis , I'll do the updates :) Did you mean I should just format the hashes or to remove the big hashes and replace them with something like the code below? expected_data = {
'data' => serialize_primary(post, {serializer: MyApp::PostSerializer}),
'included' => [
serialize_primary(post.long_comments.first, {serializer: MyApp::LongCommentSerializer}),
serialize_primary(post.long_comments.last, {serializer: MyApp::LongCommentSerializer}),
serialize_primary(post, { serializer: MyApp::PostSerializer }),
serialize_primary(post.author, {serializer: MyAppOtherNamespace::UserSerializer})
],
} I have tried this option first and then I replaced it with the direct big hash because {
"relationships"=> {
"user"=> {
"links"=> {
"self"=>"/long-comments/2/relationships/user",
"related"=>"/long-comments/2/user"
},
"data"=> { # this data bit was missing for each included resource
"type"=>"users",
"id"=>"2"
}
}
}
} Maybe there is some special option that would include this |
b47fdb3
to
b08f9da
Compare
By the way, I have already included the comment you asked, formatted the hash and squashed my commits in case that was the only thing missing :) |
Sorry I meant getting it to use the The serialize_primary(post, {
serializer: MyApp::PostSerializer,
include_linkages: ['author'],
}) |
Got it, thanks for letting me know about the include_linkages. I have updated the specs accordingly, please have a look at the updated pull request @fotinakis |
This looks great! 👍 I'll merge this tomorrow, just need to think through the correct way to notate the change and I want to test it with my own app. I think this is relatively safe because 1) it brings it into compatibility with the JSON:API spec, and 2) it's just adding more data to compound documents, not removing anything or changing a format, so I believe this is backwards compatible and we can classify it a "bugfix". |
Include intermediate resources on compound documents
Released in gem v0.6.1, thanks for your contribution. |
Please see #49