Pagination, sorting and filtering of related resources no longer work properly
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- ruby
- Domain
- backend-api-design
Research direction
Start in RelationshipBuilder and compare the relationship_name and associated_records_method_name define_on_resource blocks. Trace records_for_comments for an overridden relationship, then verify that sorting, filtering, and pagination still apply when the custom method is used. The issue does not mention a test file, so identify the relevant relationship behavior tests before making the change.
Written by the indexing model from the issue text.
Description
After upgrading to 0.9.0, when records for a relationship is overridden in the resource, pagination, sorting and filtering no longer works. Example, we have a UserResource and it has a has_many :comments relationship and on the resource, we override the method like:
def records_for_comments(_options = {})
# do some custom stuff here
end
After debugging, I can see that this is because from the older versions, in RelationshipBuilder, the logic where the records are sorted, filtered and paginated in the block:
define_on_resource relationship_name do |options = {}|
# . . .
end
are moved to this block:
define_on_resource associated_records_method_name do |options = {}|
# . . .
end
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JSONAPI-Resources/jsonapi-resources
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 3/5 1-2 days Newbie friendliness 50/100
JSONAPI-Resources/jsonapi-resources#1488 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
JSONAPI-Resources/jsonapi-resources#1479 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
JSONAPI-Resources/jsonapi-resources#1477 · 3 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in JSONAPI-Resources/jsonapi-resources
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ai-generated
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hanami/hanami-cli#449 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hanami/hanami-router#310 ·