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

Include 'meta' key when serializing relationship? #135

Open
mecampbellsoup opened this issue Nov 26, 2020 · 0 comments
Open

Include 'meta' key when serializing relationship? #135

mecampbellsoup opened this issue Nov 26, 2020 · 0 comments

Comments

@mecampbellsoup
Copy link

According to jsonapi-rb it is possible to define a meta key when serializing a resource's relationship(s) documents.

My use case is that, when requesting e.g. /api/v1/jobs/:job_id to fetch a serialized job record (that has many related outputs, i.e. a job produces outputs), I want to see some metadata describing the number of outputs associated with the job:

{
  "data": {
    "type": "jobs",
    "id": "1",
    "attributes": {
      ...
    },
    "relationships": {
      "outputs": {
        "self": "/api/jobs/1/relationships/outputs",
        "related": "/api/jobs/1/outputs",
        "meta": {
          "count": 12
        }
      }
    }
  }
}

Is this possible to do using this library? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant