Skip to content

Include 'meta' key when serializing relationship? #135

@mecampbellsoup

Description

@mecampbellsoup

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions