-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[WIP] Nested Sideloading for the JSON adapter #1107
Conversation
|
||
# development dependencies, cause... how can you not use these? :-) | ||
spec.add_development_dependency "pry-byebug" | ||
spec.add_development_dependency "awesome_print" |
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.
So, two very opinionated comments
- I try to only include dev deps in the gemspec if they are required to run tests. It sort of doesn't matter because gem test is dead, but still
- Make Adapters registerable so they are not namespace-constrained #1017 (comment) would let you use your own local gems
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.
Thanks, I'll apply that method of local debugging tools!
c95cf45
to
ee11100
Compare
Implementation idea for sideloading to help out JS Frameworks Implementation idea for sideloading to help out JS Frameworks added tests for sideloading and binding.pry for debugging added configuration option for sideloading associations switching computers tests pass revert require of dev-friendly gems - as they aren't as compatible as AMS is aiming to be also fixed a bug introduced by the sideloading - no existing tests caught the bug before initial push added a test for has_one Why does steve show up twice be more explicit about what gets added to the associations all tests passing minor renaming refactor remove gemfile.local
ee11100
to
22f63f4
Compare
# throughout the entire tree. | ||
# | ||
# Do we want a way to limit this? | ||
serialize_hash(options) |
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.
yes!. max depth of 3 or 4 should be good, imho.
Related issues
- https://github.com/rails-api/active_model_serializers/pull/1073/files#r38325279 (definitely see this!)
- Infinite loop in circular associations #211 (comment)
- Limiting stack depth association embeds #540
- Fix infinite recursion #722
- Rendering array objects that doesn't have serializers #962
- 2e791b6
I know rubygems has a good recursive resolution lib (molinillo)
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.
what if, for a particular serializer's associations, depth could be defined by using the include
keyword?
something like this:
class BlogSerializer < ...
has_many :posts, include: [:author, comments: :authors]
that way, we'd only get exactly what we expect in the json?
- 1 blog
- posts on the blog
- however many authors
- however many comments
If only those 4 models existed with this current implementation, I think It'd end up returning the whole database. lol
So, based on my other PR, #1111, I think it may be possible to maybe have some sort of sideloading wrapper, assuming that some of the new methods in #1111 could be also defined in the other adapters - sort if using an interface-ish pattern. And then sideloading would just override the serialization of an association / array? perhaps? |
Out of date. |
Hey all,
I took another stab at side loading (other PR is at #1088).
This time, it's all in a different adapter.
I'm 100% sure I've completely ignored how the cache works - but!, the logic is there.. so that's good... For the sake of prototyping, the
@associations
variable is a cache local to the specific adapter.Any prelim feedback is gladly welcomed.