-
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
Enable filtering of fields in nested assocation #2278
Enable filtering of fields in nested assocation #2278
Conversation
Have you looked at #2223 ? |
No, I didn't know #2223 . |
@south37 I need someone to test it against their app as I don't have a live app to run against at this time. |
@bf4 no one did the testing? |
Hi @johan-smits, would you mind writing a solid test to support this PR? |
@wasifhossain take a look at #2223 It has a test in it and tries a little harder to unify the adapters by using the 'fieldset' object |
@wasifhossain I will try, I'm not familiar with the codebase but will make some time available to add one. |
@johan-smits we would appreciate your time and effort. But the fact that #2223 already addressed the issue in a robust way that this PR is trying to achieve, we should better wait for that PR to be merged soon. I think @bf4 can confirm the case. Thanks. |
@wasifhossain Thats sounds good, will wait for the PR to merge, will this also become soon in a gem release? |
Hi @johan-smits, can you please try the changes on #2223 for the purpose and share your valuable feedback with us in that thread? Receiving positive feedback would help us merge that change with confidence :) |
@wasifhossain I'll continue my feedback on the #2223 issue |
closing this as #2223 is merged |
Purpose
Filtering nested association's fields.
Changes
Consider the case in which
User
,Profile
,UserSerializer
,ProfileSerializer
are defined as below.user
is defined as below.We compare the result of
ActiveModelSerializers::SerializableResource.new(user, adapter: :json, fields: [:registered], include: { profile: { only: [:birthday] } }).serializable_hash
.Before
We cannot filter fields in nested associations, so all fields of
profile
are returned.After
By applying this PR, we can filter fields in nested associations by using
only
keyword as below.Caveats
Nothing
Related GitHub issues
#1895
Additional helpful information
We use this patch in production.