Title: Use `records` for joined resources · Issue #1308 · JSONAPI-Resources/jsonapi-resources · GitHub
Open Graph Title: Use `records` for joined resources · Issue #1308 · JSONAPI-Resources/jsonapi-resources
X Title: Use `records` for joined resources · Issue #1308 · JSONAPI-Resources/jsonapi-resources
Description: This issue is a (choose one): Problem/bug report. Feature request. Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead. Checklist before submitting: I've searched for an existing issu...
Open Graph Description: This issue is a (choose one): Problem/bug report. Feature request. Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead. Checklist before submit...
X Description: This issue is a (choose one): Problem/bug report. Feature request. Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead. Checklist before submit...
Opengraph URL: https://github.com/JSONAPI-Resources/jsonapi-resources/issues/1308
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use `records` for joined resources","articleBody":"## This issue is a (choose one):\r\n\r\n- [ ] Problem/bug report.\r\n- [x] Feature request.\r\n- [ ] Request for support. **Note: Please try to avoid submitting issues for support requests. Use [Gitter](https://gitter.im/cerebris/jsonapi-resources) instead.** \r\n\r\n## Checklist before submitting:\r\n\r\n- [ ] I've searched for an existing issue.\r\n- [ ] I've asked my question on [Gitter](https://gitter.im/cerebris/jsonapi-resources) and have not received a satisfactory answer.\r\n- [ ] I've included a complete [bug report template](https://github.com/cerebris/jsonapi-resources/blob/master/lib/bug_report_templates/rails_5_master.rb). This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.\r\n- [X] The feature I'm asking for is compliant with the [JSON:API](http://jsonapi.org/) spec.\r\n\r\n## Description\r\n\r\n**Current:**\r\n\r\nIn version 0.9 and earlier JR relied on the Rails eager loading using the ActiveRecord `includes`. In a typical Rails app this feature works great, but we ran into a lot of edge cases and performance compromises when auto generating the queries JR needs for complex requests - especially ones with complex includes. In addition the complexity grew with caching.\r\n\r\nWith this approach we recommended that related resources be controlled using `relation_name` on the relationship. This relation was used in the includes and provides a way to control the related resources.\r\n\r\nWith version 0.10 the approach was changed and we no longer use rails eager loading. The `relation_name` on the relationship can still be used for relationship filtering.\r\n\r\nThere is also the option of using the `apply_join` callable on the relationship.\r\n\r\nBoth of the above options however require explicitly wiring up the appropriate code on each relationship.\r\n\r\n**Proposed change:**\r\n\r\nWhen joining related records in `ActiveRelationResource.apply_join` we have to opportunity to use ActiveRecord's `merge` method to apply the related resource's `records` logic. The implication of this is all accesses to a Resource will use the same `records` applied logic whether coming to the resource as the primary resource in a request, as an included resource, or through the `related` link of the parent resource.\r\n\r\nI believe this one change should drastically simplify resource authentication and opens up some further opportunities to further simplify most resources.\r\n","author":{"url":"https://github.com/lgebhardt","@type":"Person","name":"lgebhardt"},"datePublished":"2020-02-10T13:10:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1308/jsonapi-resources/issues/1308"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a7a4927b-b461-9f5e-e651-0261fde89104 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E99C:47EDE:1C0D0D9:281E34C:6A4F7F10 |
| html-safe-nonce | a1be5dc0aebde2f624ec0792099ea2a8ee8a6a0cc1194db8d421c4fe42265f1e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTlDOjQ3RURFOjFDMEQwRDk6MjgxRTM0Qzo2QTRGN0YxMCIsInZpc2l0b3JfaWQiOiI1NDQ5OTA1NjE1OTUzNDI4MjQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fad7cd7d9c0acd794fe89864bca5ee2538f01489a7e38ad44baf4b7991807907 |
| hovercard-subject-tag | issue:562550275 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JSONAPI-Resources/jsonapi-resources/1308/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3aa2629de07ee5031af379a9b99592fb879266989eedfdeaf8dbf87300bc3ee/JSONAPI-Resources/jsonapi-resources/issues/1308 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3aa2629de07ee5031af379a9b99592fb879266989eedfdeaf8dbf87300bc3ee/JSONAPI-Resources/jsonapi-resources/issues/1308 |
| og:image:alt | This issue is a (choose one): Problem/bug report. Feature request. Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead. Checklist before submit... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lgebhardt |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/JSONAPI-Resources/jsonapi-resources git https://github.com/JSONAPI-Resources/jsonapi-resources.git |
| octolytics-dimension-user_id | 262422067 |
| octolytics-dimension-user_login | JSONAPI-Resources |
| octolytics-dimension-repository_id | 18248068 |
| octolytics-dimension-repository_nwo | JSONAPI-Resources/jsonapi-resources |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 18248068 |
| octolytics-dimension-repository_network_root_nwo | JSONAPI-Resources/jsonapi-resources |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width