-
Notifications
You must be signed in to change notification settings - Fork 35
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
Examples & Comparison #5
Comments
Hi @oyeanuj , The motivation behind Panko is to achieve better performance at serializing ActiveRecord objects than ActiveModelSerializers (If you want to read how this done - feel free to read: https://github.com/yosiat/panko_serializer/wiki/Design-Choices) Currently, Panko is 20% compatible with AMS 0.9.7 - you can create serializer, specify relationships - the simple things. the complicated things like Today, I am working on making Panko more stable and doing some real load tests, once it's all finished Panko will be released officially and it will have documentation. If you have more questions/suggestions, feel free. |
@yosiat This sounds exciting, thank you for pointing me to the writeup! I am looking forward to be able to try this, especially since I am on the abandoned AMS 0.9x train. Maybe I'll mention the things that I liked and feel like are missing from AMS experience so that you can consider incorporating some version of them in
Being able to say something like this below would be super cool in class UserSerializer < Panko::Serializer
attributes :name, :age, :email
has_many :posts,
only: [:title, :postable]
def name
"#{object.first_name} #{object.last_name}"
end
end
class PostSerializer < Panko::Serializer
attributes :post_id, :title
has_one :postable,
polymorphic: true,
only: [:images, :audio, text: [:body]]
end
# This example would also have ImageSerializer, AudioSerialize, TextSerializer..
#...called in MembersController
paginate json: @members
Thoughts? |
Hi! Panko was build to be minimal so I can get it running at my workplace and get performance improvements. therefore the features you will see in panko are minimal (and there is a new feature for some specific case).
I added the inference feature requests as issues and tagged them for "Stable Release" milestone - https://github.com/yosiat/panko_serializer/milestone/1 If you want, we can discuss some missing features and I'll help you implement them via PR. |
@yosiat Thank you for the reply, all of this sounds good. On caching: I think especially since One more thing that came to my mind that I see used: camelCasing of keys which is super useful in integrating with JS code. Looking forward to the stable release! |
@yosiat Just wanted to get a sense of when do you see the inference features becoming a part of the library? It would help me decide if I can start migrating now or need to wait. Excited to be able to move to Panko! |
@oyeanuj it was crucial for me before working on the inference to make sure panko is working correctly, safely and fast on production. Now that I finish with the above, I plan this week to work on the inference. you will write: The only issue I see is if Panko & AMS are installed on the same project (which make sense, during a migration process, half deployment, etc) who will take precedence? |
@yosiat Yes, talking about the same thing. Additionally, if in another serializer, I write: has_many :posts,
except: [:body] It should ideally be able to infer that the association has As for precedence, do you think a configuration setting in controller or initializer would be enough? Maybe something along the lines of? use_panko_as_serializer_for [Post, Comment] |
@yosiat It seems like the example I was talking about above might be achieved with Nested Filters but I have a couple of questions on it -
Here is an example of what inside the serializer would look like - class PostSerializer < Panko::Serializer
attributes :post_id, :title
has_one :postable,
polymorphic: true,
only: [:images, :audio, text: [:body]]
end |
|
@yosiat Got it, that means the a snippet like this is supported? has_many :comments,
only: [:id, :author_name] Maybe this can be added to the docs as well, in the Associations page? |
@oyeanuj the issue is getting longer :) let's try to close it.. the
LMK if you want to make PR if not, I'll make one over the weekend. |
Hi @yosiat, I came across this while looking for alternatives to AMS. This looks intriguing, and I am wondering if you have any documenation or examples of its usage anywhere?
I am also curious on the motivations behind this library, and how it compares to AMS?
Thank you!
The text was updated successfully, but these errors were encountered: