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
Improved linked items, nested documents #10
Conversation
Interesting idea and thanks for your contribution, I'm up for changes! I've always wanted to keep the data fetching and the serialisation logic apart. To me it's not obvious that you always have a model layer with populated relations upon serialisation. That's why I kept them separate. But then on the other hand I kind of like the fact that we can use meta data to traverse the graph when you do we have a populated model layer. How do you solve the problem of having 1 + N database queries when using this? Do you run some function to populate all relations up front before serialising? |
How we get to the input data structure is an entirely different subject. In my case, the second nesting can be obtained as part of the same query. It's just a matter of packing the data structure in a meaningful way. I'll get to some finishing touches later this week. |
I guess it's a different subject yes, I was just curious on how you solved it in your case. 😄 Looking forward to your finishing touches and to merge this pull request. |
…inks along with the linked items, centralize building of the links and linked structures for the output
…de of the collect mode
This should be about complete.
|
@@ -80,6 +80,22 @@ json = PostResponder.respond(post, linked={'comments': post['comments']}) | |||
|
|||
``` | |||
|
|||
Alternatively, the linked items can be automatically collected. The resulting structure will be the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could mention how they'll be collected.
Great stuff @lphuberdeau, I like the general idea, I just had some comments on naming. Perhaps we can invest some more time on make the code a bit more readable? |
Turns out most of this is useless now as the JSONAPI spec changed entirely overnight. |
@lphuberdeau Yeah, bah. 😢 |
Playing around with the library, I ran into issues working with nested documents. Seemed like given all the meta-data available, having to collect the linked documents was un-necessary.
At this time, there is a missing entry in links that should get autopopulated. All available links are searched for in nested documents. It should likely be the same behavior for top level.
Are you open to such changes?