Skip to content
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

[JsonApiSerializer] Relationship metadata and pagination (for many-to-many) #339

Open
marcaube opened this issue Oct 24, 2016 · 2 comments
Labels

Comments

@marcaube
Copy link

From the JSON API documentation:

A “relationship object” MUST contain at least one of the following:

  • links: a links object containing at least one of the following:
    • self: a link for the relationship itself (a “relationship link”). This link allows the client to directly manipulate the relationship. For example, removing an author through an article’s relationship URL would disconnect the person from the article without deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data. (See Fetching Relationships.)
    • related: a related resource link
  • data: resource linkage
  • meta: a meta object that contains non-standard meta-information about the relationship.

A relationship object that represents a to-many relationship MAY also contain pagination links under the links member, as described below.

It seems meta information like pagination is lost when side-loading resources in a many-to-many relationship. It works correctly in a one-to-many relationship though. According to the spec, it should be possible to serialize this information, although the documentation is vague on how to paginate included resources in a many-to-many-relationship. Custom meta values should not be a problem.

My use case is that I have a list of contractors, and each of them have projects. When I list contractors, I also want to fetch (side load) a small sample of projects (one page), and display how many more there are (the "total" key from the pagination metadata).

GET /contractors?include=projects&fields[projects]=name,cost,image
@saminanirmala
Copy link

I didnot get meta in one to many relationship as well.Is this issue ??

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 4 weeks if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants