You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When including related resources in a request, all associated records are returned, which can lead to performance issues and excessive data transfer when dealing with larger datasets.
defmoduleUserViewdodeffieldsdo[:name]enddeflinks(data,conn)whennotis_list(data)do# Some actual pagination logic%{first: "foo",last: "bar",next: "baz",prev: "bang"}enddefrelationshipsdo[posts: PostView]endend
When a request to /users/1?include=posts is made, ideally the ability to limit the number of posts returned in a given request and to paginate the nested relationship. Currently, this does not exist and because of the special treatment of the links callback, it is merged into the data key as well as the top level document.
I believe allowing for paginating nested relationships requires being less prescriptive about the usage of links. I acknowledge that pagination is outside the scope of this lib; with that in mind, I believe a change made to resolve this issue would further emphasize the line between pagination and JSONAPI serialization.
While it would be a significant change, I believe links should be removed as a responsibility of this lib. This can be handled by allowing other keys to be merged in when render is called:
However, everything I've come up with to back the above style of configuration has only furthered the coupling between this lib and pagination, which would seem to move things in the wrong direction.
Thoughts?
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as "stale:discard". We are sorry that we haven't been able to prioritize it yet.
If this issue still relevant, please leave any comment if you have any new additional information that helps to solve this issue. We encourage you to create a pull request, if you can. We are happy to help you with that.
When including related resources in a request, all associated records are returned, which can lead to performance issues and excessive data transfer when dealing with larger datasets.
Example
When a request to
/users/1?include=posts
is made, ideally the ability to limit the number of posts returned in a given request and to paginate the nested relationship. Currently, this does not exist and because of the special treatment of thelinks
callback, it is merged into thedata
key as well as the top level document.Proposed Solution
I believe allowing for paginating nested relationships requires being less prescriptive about the usage of
links
. I acknowledge that pagination is outside the scope of this lib; with that in mind, I believe a change made to resolve this issue would further emphasize the line between pagination and JSONAPI serialization.While it would be a significant change, I believe
links
should be removed as a responsibility of this lib. This can be handled by allowing other keys to be merged in whenrender
is called:That way a request like
/users/1?include=posts&page[posts][number]=1&page[posts][size]=10
could be made.There may be a better way to handle this within the context of the current relationships definition as well.
However, everything I've come up with to back the above style of configuration has only furthered the coupling between this lib and pagination, which would seem to move things in the wrong direction.
Thoughts?
The text was updated successfully, but these errors were encountered: