Skip to content
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

Closed

Conversation

NullVoxPopuli
Copy link
Contributor

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.


# development dependencies, cause... how can you not use these? :-)
spec.add_development_dependency "pry-byebug"
spec.add_development_dependency "awesome_print"
Copy link
Member

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

  1. 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
  2. Make Adapters registerable so they are not namespace-constrained #1017 (comment) would let you use your own local gems

Copy link
Contributor Author

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!

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
# throughout the entire tree.
#
# Do we want a way to limit this?
serialize_hash(options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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

@NullVoxPopuli
Copy link
Contributor Author

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?

@NullVoxPopuli NullVoxPopuli changed the title Nested Sideloading (Incremental) [WIP] Nested Sideloading for the JSON adapter Sep 4, 2015
@NullVoxPopuli
Copy link
Contributor Author

Out of date.
Sideloading depends on which upcoming refactors to the json adapter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants